1.Describe a Θ(n lg n)-time algorithm that, given a set S of n integers and another integer x, determines whether or not there exist two elements in S whose sum is exactly x. (Implement exercise 2.3-7.)
上傳時間: 2017-04-01
上傳用戶:糖兒水嘻嘻
1.Describe a Θ(n lg n)-time algorithm that, given a set S of n integers and another integer x, determines whether or not there exist two elements in S whose sum is exactly x. (Implement exercise 2.3-7.) #include<stdio.h> #include<stdlib.h> void merge(int arr[],int low,int mid,int high){ int i,k; int *tmp=(int*)malloc((high-low+1)*sizeof(int)); int left_low=low; int left_high=mid; int right_low=mid+1; int right_high=high; for(k=0;left_low<=left_high&&right_low<=right_high;k++) { if(arr[left_low]<=arr[right_low]){ tmp[k]=arr[left_low++]; } else{ tmp[k]=arr[right_low++]; } } if(left_low<=left_high){ for(i=left_low;i<=left_high;i++){ tmp[k++]=arr[i]; } } if(right_low<=right_high){ for(i=right_low;i<=right_high;i++) tmp[k++]=arr[i]; } for(i=0;i<high-low+1;i++) arr[low+i]=tmp[i]; } void merge_sort(int a[],int p,int r){ int q; if(p<r){ q=(p+r)/2; merge_sort(a,p,q); merge_sort(a,q+1,r); merge(a,p,q,r); } } int main(){ int a[8]={3,5,8,6,4,1,1}; int i,j; int x=10; merge_sort(a,0,6); printf("after Merging-Sort:\n"); for(i=0;i<7;i++){ printf("%d",a[i]); } printf("\n"); i=0;j=6; do{ if(a[i]+a[j]==x){ printf("exist"); break; } if(a[i]+a[j]>x) j--; if(a[i]+a[j]<x) i++; }while(i<=j); if(i>j) printf("not exist"); system("pause"); return 0; }
上傳時間: 2017-04-01
上傳用戶:糖兒水嘻嘻
Many times I have been asked to explain “ briefl y ” how SDH, SONET, and the OTN “ exactly ” work. The questions came mainly from new colleagues, stu- dents, and users of these technologies, personally or via the usenet newsgroup comp.dcom.sdh - sonet. I could have referred them to the standards documents, but to provide a more consistent and clear answer I decided to write this pocket guide. The objective of this book is that it can be used both as an introduction as well as a reference guide to these technologies and their spe- cifi c standards documents.
標簽: Generation Transport Optical ComSoc Guide
上傳時間: 2020-05-27
上傳用戶:shancjb
This book intends to prepare you to define Unified Communications (UC) for yourself and then get it to work for you. Each vendor pulls together from its available products a package of features related to voice, data, messaging, and image communications. That’s UC for one vendor, but it’s unlikely to match exactly the UC from another vendor. You need a detailed specification to know what you’ll see installed.
標簽: Communications Unified VoIP and
上傳時間: 2020-06-01
上傳用戶:shancjb
This is a book on wireless communication. That usually means communica- tion by radio, though ultrasound and infrared light are also used occasion- ally. The term “wireless” has come to mean nonbroadcast communication, usually between individuals who very often use portable or mobile equip- ment. The term is rather vague, of course, and there are certainly borderline applications that are called wireless without falling exactly into the above definition.
標簽: Communication Technology Wireless
上傳時間: 2020-06-01
上傳用戶:shancjb
Fun. We (your authors) wanted a word to describe our ultimate goal for this book, as well as a word we hope you (our reader) will use to describe it, and that’s the one we chose. There are others goals, of course, but in the end, when you’ve finished the book, we’re hoping you’ll have enjoyed the activities described in these pages. Many books use the Introduction to explain exactly what the book is about, what the reader will learn, what the reader needs (a skill or maybe an item or piece of software), and what the reader will be left with when that last page is completed. And this Introduction will do those things, but … hopefully it’ll make you excited to get started.
標簽: Adventures Arduino Station Escape Gemini from
上傳時間: 2020-06-09
上傳用戶:shancjb
This book addresses programmer attitudes, but it’s not some kind of psychology textbook. We’ll investigate many topics, including: Source code presentation Defensive coding techniques How to debug programs effectively Good teamworking skills Managing your source code Take a quick glance through the table of contents to see exactly what’s covered. What is the rationale behind my selection of topics? I’ve been mentor- ing trainee programmers for many years, and these are the topics that have come up time and time again. I’ve also worked in the software factory for long enough to have seen the recurring problems—I address these too. If you can conquer all of these programming demons, you’ll progress from an apprentice coder to a real code craftsman.
標簽: excellent practice writing Craft Code code the of
上傳時間: 2021-11-09
上傳用戶:danix800
Extensively rewritten to present the C++11 language, standard library, and key design techniques as an integrated whole, Stroustrup thoroughly addresses changes that make C++11 feel like a whole new language, offering definitive guidance for leveraging its improvements in performance, reliability, and clarity. C++ programmers around the world recognize Bjarne Stoustrup as the go-to expert for the absolutely authoritative and exceptionally useful information they need to write outstanding C++ programs. Now, as C++11 compilers arrive and development organizations migrate to the new standard, they know exactly where to turn once more: Stoustrup's C++ Programming Language, Fourth Edition.Bjarne Stroustrup是C++的設計師和最早的實現者,也是《C++程序設計語言》、《帶標注的C++參考手冊》和《C++語言的設計與演化》的作者。他從丹麥Aarhus大學和英國牛津大學畢業,現在是AT&T大規模程序設計研究部的負責人,AT&T特別成員,AT&T貝爾實驗室特別成員,以及ACM特別成員。Stroustrup的研究興趣包括分布式系統、操作系統、模擬、設計和程序設計。他也是Addison·Wesley的C++In-Depth系列書籍的編輯。
標簽: C++
上傳時間: 2022-02-01
上傳用戶:
因此,您想編寫一個內核模塊。您知道C,您已經編寫了一些可以作為進程運行的常規程序,現在您想知道真正的動作在哪里,一個通配指針可以擦掉文件系統,核心轉儲意味著重新啟動。內核模塊到底是什么?模塊是可以根據需要加載和卸載的代碼段。它們擴展了內核的功能,而無需重新引導系統。例如。模塊驅動程序的一種類型是設備驅動程序,它允許內核訪問沒有模塊的系統硬件,我們將不得不構建單片內核并將新功能直接添加到內核映像中,除了具有更大的內核之外,這還具有缺點每次我們想要新功能時都要求我們重建并重新啟動內核的過程So, you want to write a kernel module. You know C, you, ve written a few normal programs to run as processes, and now you want to get to where the real action is, to where a single wild pointer can wipe out your file system and a core dump means a reboot.What exactly is a kernel module? Modules are pieces of code that can be loaded and unloaded into th upon demand. They extend the functionality of the kernel without the need to reboot the system. For example.one type of module is the device driver, which allows the kernel to access hardware connected to the syste without modules, we would have to build monolithic kernels and add new functionality directly into the em ernel image, Besides having larger kernels
標簽: linux
上傳時間: 2022-03-30
上傳用戶:
German universities and scientists have repeatedly set the intermational standard in drive technology. Identification and active compensation of natural frequencies in oscillatory mechanics, status controls with monitoring structures incorporating acceleration sensors, adaptive compensation of measurement system deficiencies, self-adjusting detent torque compensation… everything invented with only a single aim in mind: to continue improv-ing the motion control, dynamics, precision and processing speed of your machines. For the industrial applicabability of this technology scientific publications in proceedings and laboratory test rigs are not enough. These features consequenty need to be converted into cost-efficient and easily manageable products. That 's exactly what we have done.So in future, if you should need more than today ' smarket can offer you, now everything isgoing to be alright. With our new high-performance ServoOne drive series you will experi-ence
標簽: servoone
上傳時間: 2022-06-24
上傳用戶:kingwide