×
Hard work beats talent when talent doesn’t work hard.
--Your friends at LectureNotes
Close

Note for Database Management System - DBMS by Roopsingh Vankudothu

  • Database Management System - DBMS
  • Note
  • Computer Science Engineering
  • B.Tech
  • 8 Views
  • Uploaded 2 months ago
Roopsingh Vankudothu
Roopsingh Vankudothu
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-2

www.alljntuworld.in JNTU World 4 Heap 4.1 Insertion . 4.2 Deletion . 4.3 Searching 4.4 Traversal 4.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 29 30 31 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 33 37 38 41 42 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 46 46 47 47 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 49 49 49 53 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 56 57 58 59 61 . . . . . . . . . . . . . . . . . . . . . . . . . 5 Sets 5.1 Unordered . . . . 5.1.1 Insertion . 5.2 Ordered . . . . . 5.3 Summary . . . . . . . . . . . . . . . . . . . . 6 Queues 6.1 A standard queue . . 6.2 Priority Queue . . . 6.3 Double Ended Queue 6.4 Summary . . . . . . . . . . . . . . 7 AVL Tree 7.1 Tree Rotations . 7.2 Tree Rebalancing 7.3 Insertion . . . . . 7.4 Deletion . . . . . 7.5 Summary . . . . . . . . . . . . . . W . . . . . . . . . or ld 3.8 3.7.2 Postorder . . 3.7.3 Inorder . . . 3.7.4 Breadth First Summary . . . . . . . . . . . TU . . . . . II Algorithms JN 8 Sorting 8.1 Bubble Sort . 8.2 Merge Sort . 8.3 Quick Sort . . 8.4 Insertion Sort 8.5 Shell Sort . . 8.6 Radix Sort . 8.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 63 63 65 67 68 68 70 9 Numeric 72 9.1 Primality Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 9.2 Base conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 9.3 Attaining the greatest common denominator of two numbers . . 73 9.4 Computing the maximum value for a number of a specific base consisting of N digits . . . . . . . . . . . . . . . . . . . . . . . . . 74 9.5 Factorial of a number . . . . . . . . . . . . . . . . . . . . . . . . 74 9.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 II Downloaded From JNTU World (http://www.alljntuworld.in)

Text from page-3

www.alljntuworld.in JNTU World 10 Searching 76 10.1 Sequential Search . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 10.2 Probability Search . . . . . . . . . . . . . . . . . . . . . . . . . . 76 10.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 . . . . . . . . . . . . 79 79 80 81 83 84 85 or ld 11 Strings 11.1 Reversing the order of words in a sentence . . . . . . . . . . . 11.2 Detecting a palindrome . . . . . . . . . . . . . . . . . . . . . 11.3 Counting the number of words in a string . . . . . . . . . . . 11.4 Determining the number of repeated words within a string . . 11.5 Determining the first matching character between two strings 11.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A Algorithm Walkthrough 86 A.1 Iterative algorithms . . . . . . . . . . . . . . . . . . . . . . . . . 86 A.2 Recursive Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . 88 A.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 B Translation Walkthrough 91 B.1 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 W C Recursive Vs. Iterative Solutions 93 C.1 Activation Records . . . . . . . . . . . . . . . . . . . . . . . . . . 94 C.2 Some problems are recursive in nature . . . . . . . . . . . . . . . 95 C.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 TU D Testing D.1 What constitutes a unit test? . D.2 When should I write my tests? D.3 How seriously should I view my D.4 The three A’s . . . . . . . . . . D.5 The structuring of tests . . . . D.6 Code Coverage . . . . . . . . . D.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . test suite? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 . 97 . 98 . 99 . 99 . 99 . 100 . 100 101 JN E Symbol Definitions . . . . . . . III Downloaded From JNTU World (http://www.alljntuworld.in)

Text from page-4

www.alljntuworld.in JNTU World or ld Chapter 1 Introduction 1.1 What this book is, and what it isn’t TU W This book provides implementations of common and uncommon algorithms in pseudocode which is language independent and provides for easy porting to most imperative programming languages. It is not a definitive book on the theory of data structures and algorithms. For the most part this book presents implementations devised by the authors themselves based on the concepts by which the respective algorithms are based upon so it is more than possible that our implementations differ from those considered the norm. You should use this book alongside another on the same subject, but one that contains formal proofs of the algorithms in question. In this book we use the abstract big Oh notation to depict the run time complexity of algorithms so that the book appeals to a larger audience. 1.2 Assumed knowledge We have written this book with few assumptions of the reader, but some have been necessary in order to keep the book as concise and approachable as possible. We assume that the reader is familiar with the following: 1. Big Oh notation JN 2. An imperative programming language 3. Object oriented concepts 1.2.1 Big Oh notation For run time complexity analysis we use big Oh notation extensively so it is vital that you are familiar with the general concepts to determine which is the best algorithm for you in certain scenarios. We have chosen to use big Oh notation for a few reasons, the most important of which is that it provides an abstract measurement by which we can judge the performance of algorithms without using mathematical proofs. 1 Downloaded From JNTU World (http://www.alljntuworld.in)

Text from page-5

www.alljntuworld.in JNTU World 2 or ld CHAPTER 1. INTRODUCTION Figure 1.1: Algorithmic run time expansion W Figure 1.1 shows some of the run times to demonstrate how important it is to choose an efficient algorithm. For the sanity of our graph we have omitted cubic O(n3 ), and exponential O(2n ) run times. Cubic and exponential algorithms should only ever be used for very small problems (if ever!); avoid them if feasibly possible. The following list explains some of the most common big Oh notations: TU O(1) constant: the operation doesn’t depend on the size of its input, e.g. adding a node to the tail of a linked list where we always maintain a pointer to the tail node. O(n) linear: the run time complexity is proportionate to the size of n. O(log n) logarithmic: normally associated with algorithms that break the problem into smaller chunks per each invocation, e.g. searching a binary search tree. JN O(n log n) just n log n: usually associated with an algorithm that breaks the problem into smaller chunks per each invocation, and then takes the results of these smaller chunks and stitches them back together, e.g. quick sort. O(n2 ) quadratic: e.g. bubble sort. O(n3 ) cubic: very rare. O(2n ) exponential: incredibly rare. If you encounter either of the latter two items (cubic and exponential) this is really a signal for you to review the design of your algorithm. While prototyping algorithm designs you may just have the intention of solving the problem irrespective of how fast it works. We would strongly advise that you always review your algorithm design and optimise where possible—particularly loops Downloaded From JNTU World (http://www.alljntuworld.in)

Lecture Notes