-
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;
}
標簽:
c語言
算法
排序
上傳時間:
2017-04-01
上傳用戶:糖兒水嘻嘻
-
Wireless technologies like GSM, UMTS, LTE, Wireless LAN and Bluetooth have
revolutionized the way we communicate by making services like telephony and Internet
access available anytime and from almost anywhere. Today, a great variety of technical
publications offer background information about these technologies but they all fall
short in one way or Another. Books covering these technologies usually describe only
one of the systems in detail and are generally too complex as a first introduction. The
Internet is also a good source, but the articles one finds are usually too short and super-
ficial or only deal with a specific mechanism of one of the systems. For this reason, it
was difficult for me to recommend a single publication to students in my telecommunication
classes, which I have been teaching in addition to my work in the wireless telecommunication
industry. This book aims to change this.
標簽:
LTE-Advanced
From
GSM
Pro
and
5G
to
上傳時間:
2020-05-27
上傳用戶:shancjb
-
This book is an entry-level text on the technology of telecommunications. It has been
crafted with the newcomer in mind. The twenty-one chapters of text have been prepared
for high-school graduates who understand algebra, logarithms, and the basic principles of
electricity such as Ohm’s law. However, it is appreciated that many readers require support
in these areas. Appendices A and B review the essentials of electricity and mathematics
up through logarithms. This material was placed in the appendices so as not to distract
from the main theme, the technology of telecommunication systems. Another topic that
many in the industry find difficult is the use of decibels and derived units. Appendix C
provides the reader a basic understanding of decibels and their applications. The only
mathematics necessary is an understanding of the powers of ten
標簽:
Telecommunications
Fundamentals
2nd
of
ed
上傳時間:
2020-05-27
上傳用戶:shancjb
-
Someone who wants to get to know the customs of a country frequently
receives the advice to learn the language of that country. Why? Because the dif-
ferences that distinguish the people of one country from those of Another are
reflected in the language. For example, the people of the islands of the Pacific
do not have a term for war in their language. Similarly, some native tribes in
the rain forests of the Amazon use up to 100 different terms for the color green.
標簽:
Networks
GSM
上傳時間:
2020-05-27
上傳用戶:shancjb
-
Wireless technologies like GSM, UMTS, LTE, Wireless LAN and Bluetooth have revolu-
tionized the way we communicate and exchange data by making services like telephony and
Internet access available anytime and from almost anywhere. Today, a great variety of techni-
cal publications offer background information about these technologies but they all fall short
in one way or Another. Books covering these technologies usually describe only one of the
systems in detail and are generally too complex as a first introduction. The Internet is also a
good source, but the articles one finds are usually too short and superficial or only deal with
a specific mechanism of one of the systems. For this reason, it was difficult for me to recom-
mend a single publication to students in my telecommunication classes, which I have been
teaching in addition to my work in the wireless telecommunication industry. This book aims
to change this.
標簽:
GSM
LTE-Advanced
上傳時間:
2020-05-27
上傳用戶:shancjb
-
Do you have a mobile phone? We think you probably do, one way or Another. We
would also guess that you might use it for many diff erent things in the course of your
everyday life—as a telephone certainly, but also as an address book, as a clock or
watch, as a camera, or now as a connection to your computer, email and the internet.
Th ere will be a range of people you use it to contact (or not), and various strategies
you use to take calls—or send texts, or take photos, or receive emails, or search online
(or not, in diff erent situations). Th ere are also likely to be a range of social relation-
ships in your life that your mobile phone helps to maintain—or disrupts, or inter-
venes in, or makes possible, or complicates, or just plain helps to handle.
標簽:
Communications
Introduction
Mobile
Media
New
An
to
上傳時間:
2020-05-30
上傳用戶:shancjb
-
Theartofcomputationofelectromagnetic(EM)problemshasgrownexponentially
for three decades due to the availability of powerful computer resources. In spite of
this, the EM community has suffered without a suitable text on the computational
techniques commonly used in solving EM-related problems. Although there have
been monographs on one particular technique or Another, the monographs are written
for the experts rather than students. Only a few texts cover the major techniques and
dothatinamannersuitableforclassroomuse.Itseemsexpertsinthisareaarefamiliar
with one or a few techniques but not many seem to be familiar with all the common
techniques. This text attempts to fill that gap.
標簽:
Electromagnetics
Techniques
Numerical
in
上傳時間:
2020-05-31
上傳用戶:shancjb
-
It is more than a decade since GSM was first commercially available. After some unexpected delay, it
seems that finally UMTS is here to stay as a 3G system standardised by 3GPP, at least for Another ten
years. UMTS will enable multi-service, multi-rate and flexible IP native-based mobile technologies to be
used in wide area scenarios and also pave the way for a smooth transition from circuit switched voice
networks to mobile packet services.
標簽:
Management
Strategies
Resource
Radio
上傳時間:
2020-06-01
上傳用戶:shancjb
-
The first gem of wisdom I ever acquired about consulting, obtained many years ago
from a former schoolmate, was to ensure that everything is plugged in: no continuity, no
data. Wires carry voltages and currents from one place to Another. Their behavior is
reasonably simple and predictable—at least for sufficiently low data rates and short
lengths—and they can be seen, grabbed, traced, and tugged.
標簽:
RF Engineering
上傳時間:
2020-06-01
上傳用戶:shancjb