

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Some concept of Data Structures and Algorithm are Permutation, Representation, Implemented, Algorithm Design, Dynamic Programming, Graph Data Structures, String Processing, General Trees. Main points of this lecture are: Elementary Data Structures, Problem, Day, Data, Base, Asymptotically Important, Recall, Matter, Sentencing Guidelines, Federal
Typology: Slides
1 / 25
This page cannot be seen from the preview
Don't miss anything!


















True or False?
n = O(log n)
n)
n) = O(n^2 log n)
n = O(n^2 )
n log n = O(n)
2F1.1. Fraud and Deceit; Forgery; Offenses Involving Altered or Counterfeit Instruments other than Counterfeit Bearer Obligations of the United States.(a) Base offense Level: 6 (b) Specific offense Characteristics (1) If the loss exceeded $2,000, increase the offense level as follows: Loss(Apply the Greatest)(A) $2,000 or less Increase in Levelno increase (B) More than $2,000(C) More than $5,000 add 1add 2 (D) More than $10,000(E) More than $20,000 add 3add 4 (F) More than $40,000(G) More than $70,000 add 5add 6 (H) More than $120,000(I) More than $200,000 add 7add 8 (J) More than $350,000(K) More than $500,000 (^) add 10add 9 (L) More than $800,000(M) More than $1,500,000 add 11add 12 (N) More than $2,500,000(O) More than $5,000,000 add 13add 14 (P) More than $10,000,000(Q) More than $20,000,000 add 15add 16 (R) More than $40,000,000(Q) More than $80,000,000 add 17add 18
The increase in punishment level grows logarithmically in the amount of money stolen. Thus it pays to commit one big crime rather than many small crimes totalling the same amount.
That we can describe the behavior of our data structures in terms of abstract operations is why we can use them without thinking. That there are different implementations of the same abstract operations enables us to optimize performance.
Data structures can be neatly classified as either contiguous or linked depending upon whether they are based on arrays or pointers:
Unfortunately we cannot adjust the size of simple arrays in the middle of a program’s execution. Compensating by allocating extremely large arrays can waste a lot of space. With dynamic arrays we start with an array of size 1, and double its size from m to 2 m each time we run out of space. How many times will we double for n elements? Only dlog 2 ne.
The apparent waste in this procedure involves the recopying of the old contents on each expansion. If half the elements move once, a quarter of the elements twice, and so on, the total number of movements M is given by
M =
lg∑ n i=
i · n/ 2 i^ = n
lg∑ n i=
i/ 2 i^ ≤ n
∞∑ i=
i/ 2 i^ = 2n
Thus each of the n elements move an average of only twice, and the total work of managing the dynamic array is the same O(n) as a simple array.
typedef struct list { item type item; struct list *next; } list;
Lincoln Jefferson Clinton NIL
Searching in a linked list can be done iteratively or recursively.
list (^) *search list(list (^) *l, item type x) { if (l == NULL) return(NULL); if (l− >item == x) return(l); else return( search list(l− >next, x) ); }
delete list(list (^) **l, item type x) { list (^) p; ( item pointer (^) *) list (^) last = NULL; ( predecessor pointer (^) *) p = (^) l; while (p− >item != x) { ( find item to delete (^) ) last = p; p = p− >next; } if (last == NULL) ( splice out of the list (^) *) else l^ =^ p−^ >next; last− >next = p− >next; free(p); ( return memory used by the node (^) *) }
The relative advantages of linked lists over static arrays include:
Dynamic memory allocation provides us with flexibility on how and where we use our limited storage resources.
Both can be used to store nodes to visit in a tree, but the order of traversal is completely different.
1
2 3
4 5 6 7
1
5 2
7 6 4 3 Queue Stack
Which order is friendlier for WWW crawler robots?
Perhaps the most important class of data structures maintain a set of items, indexed by keys.