×
DON'T BE SATISFIED WITH B when you can get A+
--Your friends at LectureNotes
Close

Note for Data Structures through C++ - DSCPP by Naresh Babu

  • Data Structures through C++ - DSCPP
  • Note
  • 6 Topics
  • 4277 Views
  • 138 Offline Downloads
  • Uploaded 8 months ago
Naresh Babu
Naresh Babu
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-2

index = (index + 2) % hashTableSize index = (index + 3) % hashTableSize and so on… Hash collision is resolved by open addressing with linear probing. Since CodeMonk and Hashing are hashed to the same index i.e. 2, store Hashing at 3 as the interval between successive probes is 1. Implementation of hash table with linear probing Assumption • • • There are no more than 20 elements in the data set. Hash function will return an integer from 0 to 19. Data set must have unique elements. Hash collision is resolved by open addressing with linear probing. Since CodeMonk and Hashing are hashed to the same index i.e. 2, store Hashing at 3 as the interval between successive probes is 1. Implementation of hash table with linear probing Assumption • • • There are no more than 20 elements in the data set. Hash function will return an integer from 0 to 19. Data set must have unique elements.

Text from page-3

• (1,20) • (2,70) • (42,80) • (4,25) • (12,44) • (14,32) • (17,11) • (13,78) • (37,98) Sr.No. Key Hash Array Index 1 1 1 % 20 = 1 1 2 2 2 % 20 = 2 2 3 42 42 % 20 = 2 2 4 4 4 % 20 = 4 4 5 12 12 % 20 = 12 12 6 14 14 % 20 = 14 14 7 17 17 % 20 = 17 17

Text from page-4

8 13 13 % 20 = 13 13 9 37 37 % 20 = 17 17 Sr.No. Key Hash Array Index After Linear Probing, Array Index 1 1 1 % 20 = 1 1 1 2 2 2 % 20 = 2 2 2 3 42 42 % 20 = 2 2 3 4 4 4 % 20 = 4 4 4 5 12 12 % 20 = 12 12 12 6 14 14 % 20 = 14 14 14 7 17 17 % 20 = 17 17 17 8 13 13 % 20 = 13 13 13 9 37 37 % 20 = 17 17 18

Text from page-5

Circular Queue In a normal Queue Data Structure, we can insert elements until queue becomes full. But once if queue becomes full, we can not insert the next element until all the elements are deleted from the queue. For example consider the queue below... After inserting all the elements into the queue. Now consider the following situation after deleting three elements from the queue... This situation also says that Queue is Full and we can not insert the new element because, 'rear' is still at last position. In above situation, even though we have empty positions in the queue we can not make use of them to insert new element. This is the major problem in normal queue data structure. To overcome this problem we use circular queue data structure. What is Circular Queue? A Circular Queue can be defined as follows...

Lecture Notes