id int64 0 25.6k | text stringlengths 0 4.59k |
|---|---|
24,600 | data structures using selection algorithms these algorithms are used to find the minimum and maximum values in linear or sub-linear time graph algorithms heaps can be used as internal traversal data structures this guarantees that runtime is reduced by an order of polynomial heaps are therefore used for implementing pr... |
24,601 | draw heap that is also binary search tree analyse the complexity of heapify algorithm consider the fibonacci heap given below and then decrease the value of node to insert new node with value and finally delete node from it min[ reheap the following structure to make it heap multiple-choice questions show the array imp... |
24,602 | data structures using true or false fill in the blanks binary heap is complete binary tree in min heapthe root node has the highest key value in the heap an element at position has its parent stored at position / all levels of binary heap except the last level are completely filled in min-heapelements at every node wil... |
24,603 | graphs learning objective in this we will discuss another non-linear data structure called graphs we will discuss the representation of graphs in the memory as well as the different operations that can be performed on them last but not the leastwe will discuss some of the real-world applications of graphs introduction ... |
24,604 | data structures using graph can be directed or undirected in an undirected graphedges do not have any direction associated with them that isif an edge is drawn between nodes and bthen the nodes can be traversed from to as well as from to figure shows an undirected graph because it does not give figure directed graph an... |
24,605 | labelled graph or weighted graph graph is said to be labelled if every edge in the graph is assigned some data in weighted graphthe edges of the graph are assigned some weight or length the weight of an edge denoted by (eis positive value which indicates the cost of traversing the edge figure (cshows weighted graph mul... |
24,606 | data structures using weakly connected digraph directed graph is said to be weakly connected if it is connected by ignoring the direction of edges that isin such graphit is possible to reach any node from any other node by traversing edges in any direction (may not be in the direction they pointthe nodes in weakly conn... |
24,607 | algorithm the algorithm to find the transitive closure of graph is given in fig in order to determine the transitive closure of graphwe define matrix where tkij for ijk if there if (ij is not in when tij exists path in from the vertex to vertex with oo if (ijis intermediate vertices in the set ( kand tikj kv ( ki - kk ... |
24,608 | data structures using as for verticesthere is related concept for edges an edge in graph is called bridge if removing that edge results in disconnected graph alsoan edge in graph that does not lie on cycle is figure bi-connected figure graph with bridge this means that bridge has at least one bridges graph articulation... |
24,609 | from the above exampleswe can draw the following conclusionsfor simple graph (that has no loops)the adjacency matrix has on the diagonal the adjacency matrix of an undirected graph is symmetric the memory use of an adjacency matrix is ( )where is the number of nodes in the graph number of (or non-zero entriesin an adja... |
24,610 | data structures using if otherwise the path matrix is used to show whether there exists simple path from node vi to vj or not this is shown in fig let us now calculate matrix and matrix using the above discussion [if there is path from vi to vjpij [otherwisefigure path matrix entry ii ii ii ii now the path matrix can b... |
24,611 | adjacency multi-list representation graphs can also be represented using multi-lists which can be said to be modified version of adjacency lists adjacency multi-list is an edge-based rather than vertex-based representation of graphs multi-list representation basically consists of two parts-- directory of nodesinformati... |
24,612 | data structures using programming example write program to create graph of vertices using an adjacency list also write the code to read and print its information and finally to delete the graph #include #include #include struct node char vertexstruct node *next}struct node *gnodevoid displaygraph(struct node *adj[]int ... |
24,613 | struct node *ptrint ifor( no_of_nodesi++ptr adj[ ]printf("\ the neighbours of node % are:" )while(ptr !nullprintf("\ % "ptr -vertex)ptr ptr -nextvoid deletegraph (struct node *adj[]int no_of_nodesint istruct node *temp*ptrfor( <no_of_nodesi++ptr adj[ ]while(ptr nulltemp ptrptr ptr -nextfree(temp)adj[inulloutput enter t... |
24,614 | data structures using breadth-first search depth-first search while breadth-first search uses queue as an auxiliary data structure to store nodes for further processingthe depth-first search scheme uses stack but both these algorithms make use of variable status during the execution of the algorithmevery node in the gr... |
24,615 | (bdequeue node by setting front front (remove the front element of queueand enqueue the neighbours of alsoadd as the orig of its neighbours front queue rear orig \ (cdequeue node by setting front front and enqueue the neighbours of alsoadd as the orig of its neighbours front queue rear orig \ (ddequeue node by setting ... |
24,616 | data structures using if the number of vertices and edges in the graph are known ahead of timethe space complexity can also be expressed as )where is the total number of edges in and is the number of nodes or vertices time complexity in the worst casebreadth-first search has to traverse through all paths to all possibl... |
24,617 | int visited[max{ }int adj[max][max]ijprintf("\ enter the adjacency matrix")for( maxi++for( maxj++scanf("% "&adj[ ][ ])breadth_first_search(adj,visited, )return output enter the adjacency matrix depth-first search algorithm the depth-first search algorithm (fig progresses by expanding the starting node of and then going... |
24,618 | data structures using adjacency lists abcd be cbg dcg ecf fch gfhi hei if figure graph and its adjacency list solution (apush onto the stack stackh (bpop and print the top element of the stackthat ish push all the neighbours of onto the stack that are in the ready state the stack now becomes printh stackei (cpop and pr... |
24,619 | hifcgbe these are the nodes which are reachable from the node features of depth-first search algorithm space complexity the space complexity of depth-first search is lower than that of breadthfirst search time complexity the time complexity of depth-first search is proportional to the number of vertices plus the number... |
24,620 | data structures using printf("\ enter the adjacency matrix")for( maxi++for( maxj++scanf("% "&adj[ ][ ])printf("dfs traversal")depth_first_search(adj,visited, )printf("\ ")return output enter the adjacency matrix dfs traversala - - - topological sorting topological sort of directed acyclic graph (dagg is defined as line... |
24,621 | step find the in-degree indeg(nof every node in the graph step enqueue all the nodes with zero in-degree step repeat steps and until the queue is empty step remove the front node of the queue by setting front front step repeat for each neighbour of node nadelete the edge from to by setting indeg(mindeg( bif indeg(mthen... |
24,622 | data structures using step remove the front element from the queue by setting front front so front rear queue agb step set indeg(dindeg( since is the neighbour of nowindeg( indeg( indeg( indeg( delete the edge from to the graph now becomes as shown in the figure below step remove the front element from the queue by set... |
24,623 | step remove the front element from the queue by setting front front so front rear queue agbcde step set indeg(findeg( since is the neighbour of now indeg( so add to the queue the queue now becomesfront rear queue agbcdef step delete the edge between and the graph now becomes as shown in the figure below there are no mo... |
24,624 | data structures using insert_queue(node)while(front <rear/*continue loop until queue is empty *del_node delete_queue()topsort[jdel_node/*add the deleted node to topsort* ++/*delete the del_node edges *for(node node <nnode++if(adj[del_node][node= adj[del_node][node indeg[nodeindeg[node if(indeg[node= insert_queue(node)p... |
24,625 | front= queue[++rearnode int delete_queue(int del_nodeif (front =- |front rearprintf("\ underflow ")return else del_node queue[front++]return del_nodeint find_indegree(int nodeint ,in_deg for( <ni++ifadj[ ][node= in_deg++return in_degoutput enter number of vertices enter edge ( to quit) enter edge ( to quit) enter edge ... |
24,626 | data structures using tree minimum spanning tree (mstis defined as spanning tree with weight less than or equal to the weight of every other spanning tree in other wordsa minimum spanning tree is spanning tree that has weights associated with its edgesand the total weight of the tree (the sum of the weights of its edge... |
24,627 | of all the spanning trees given in fig the one that is highlighted is called the minimum spanning treeas it has the lowest cost associated with it (weighted grapha (total cost (total cost (total cost (total cost (total cost (total cost (total cost (total cost (total cost figure weighted graph and its spanning trees app... |
24,628 | data structures using the running time of prim' algorithm can be given as ( log vwhere is the number of edges and is the number of vertices in the graph figure example construct minimum spanning tree of the graph given in fig graph step choose starting vertex step add the fringe vertices (that are adjacent to athe edge... |
24,629 | kruskal' algorithm kruskal' algorithm is used to find the minimum spanning tree for connected weighted graph the algorithm aims to find subset of the edges that forms tree that includes every vertex the total weight of all the edges in the tree is minimized howeverif the graph is not connectedthen it finds minimum span... |
24,630 | data structures using in the algorithmwe use priority queue in which edges that have minimum weight takes priority over any other edge in the graph when the kruskal' algorithm terminatesthe forest has only one component and forms minimum spanning tree of the graph the running time of kruskal' algorithm can be given as ... |
24,631 | {{acdef}{ }mst {(ad)(ce)(ef)(ed) {(df)(ac)(ab)(bc)step remove the edge (dffrom note that this edge does not connect different treesso simply discard this edge only an edge connecting (adcefto will be added to the mst {{acdef}{ }mst {(ad)(ce)(ef)(ed) {(ac)(ab)(bc)step remove the edge (acfrom note that this edge does not... |
24,632 | data structures using int visited[max] [max]parent[max]int ijkminuvcostfor ( <ni++ [iadj[src][ ]visited[ parent[isrcvisited[src cost for ( ni++min for ( <nj++if (visited[ ]== & [jminmin [ ] jcost + [ ]visited[ //cost cost [ ]tree[ ][ parent[ ]tree[ ++][ ufor ( <nv++if (visited[ ]== &(adj[ ][vd[ ]) [vadj[ ][ ]parent[vur... |
24,633 | enter the source the edges of the minimum spanning tree are the total cost of the minimum spanning tree is dijkstra' algorithm dijkstra' algorithmgiven by dutch scientist edsger dijkstra in is used to find the shortest path tree this algorithm is widely used in network routing protocolsmost notably is-is and ospf (open... |
24,634 | data structures using example consider the graph given in fig taking as the initial nodeexecute the dijkstra' algorithm on it step set the label of and { step label of and thereforen {dfa step label of has been re-labelled because minimum ( has been re-labelled ( thereforen {dc fc step label of thereforen {dfcbf step l... |
24,635 | there is path from vi to vk and path from vk to vj where all the nodes use vk- thereforepk- [ ][ and pk- [ ][ hencethe path matrix pn can be calculated with the formula given aspk[ ][jpk- [ ][jv (pk- [ ][kl pk- [ ][ ]where indicates logical or operation and indicates logical and operation figure shows the warshall' alg... |
24,636 | data structures using printf("\ enter the number of nodes in the graph ")scanf("% "& )printf("\ enter the adjacency matrix ")read(adjn)clrscr()printf("\ the adjacency matrix is ")display(adjn)for( = ; < ; ++for( = ; < ; ++if(adj[ ][ = [ ][ else [ ][ for( = < ; ++for( = ; < ; ++for( = ; < ; ++ [ ][jp[ ][jp[ ][kp[ ][ ])p... |
24,637 | the path matrix is modified warshall' algorithm warshall' algorithm can be modified to obtain matrix that gives the shortest paths between the nodes in graph as an input to the algorithmwe take the adjacency matrix of and replace all the values of which are zero by infinity (*infinity (*denotes very large number and in... |
24,638 | data structures using example consider weighted graph given in fig and apply warshall' shortest path algorithm to it figure graph programming example write program to implement warshall' modified algorithm to find the shortest path #include #include #define infinity void read (int mat[ ][ ]int )void display(int mat[ ][... |
24,639 | for( = ; < ; ++if( [ ][ < [ ][kq[ ][ ] [ ][jq[ ][ ]else [ ][jq[ ][kq[ ][ ]printf("\ \ ")display(qn)getch()return void read(int mat[ ][ ]int nint ijfor( = ; < ; ++for( = ; < ; ++printf("\ mat[% ][% "ij)scanf("% "&mat[ ][ ])void display(int mat[ ][ ]int nint ijfor( = ; < ; ++{printf("\ ")for( = ; < ; ++printf("% \ "mat[ ... |
24,640 | data structures using in state transition diagramsthe nodes are used to represent states and the edges represent legal moves from one state to the other graphs are also used to draw activity network diagrams these diagrams are extensively used as project management tool to represent the interdependent relationships bet... |
24,641 | breadth-first search is graph search algorithm that begins at the root node and explores all the neighbouring nodes then for each of those nearest nodesthe algorithm explores their unexplored neighbour nodesand so onuntil it finds the goal the depth-first search algorithm progresses by expanding the starting node of an... |
24,642 | data structures using differentiate between dijkstra' algorithm and minimum spanning tree algorithm consider the graph given below find the minimum spanning tree of this graph using (aprim' algorithm(bkruskal' algorithmand (cdijkstra' algorithm ae given the following adjacency matrixdraw the weighted graph briefly disc... |
24,643 | the memory use of an adjacency matrix is (ao( (bo( (co( (do(log the term optimal can mean (ashortest (bcheapest (cfastest (dall of these how many articulation vertices does biconnected graph contain( ( ( ( kruskal' algorithm is an example of greedy algorithm true or false graph with multiple edges and/or loop is called... |
24,644 | searching and sorting learning objective searching and sorting are two of the most common operations in computer science searching refers to finding the position of value in collection of values sorting refers to arranging data in certain order the two commonly used orders are numerical order and alphabetical order in ... |
24,645 | linear_search(anvalstep [initializeset pos - step [initializeset step repeat step while <= step if [ival set pos print pos go to step [end of ifset [end of loopstep if pos - print "value is not present in the array[end of ifstep exit figure algorithm for linear search and the value to be searched is val then searching ... |
24,646 | data structures using printf("\ % does not exist in the array"num)return binary search binary search is searching algorithm that works efficiently with sorted list the mechanism of binary search can be better understood by an analogy of telephone directory when we are searching for particular name in directorywe first ... |
24,647 | binary_search(alower_boundupper_boundvalstep [initializeset beg lower_bound end upper_boundpos step repeat steps and while beg <end step set mid (beg end)/ step if [midval set pos mid print pos go to step else if [midval set end mid else set beg mid [end of if[end of loopstep if pos - print "value is not present in the... |
24,648 | data structures using else if (arr[mid]>numend mid- else beg mid+ if (beg end &found = printf("\ % does not exist in the array"num)return int smallest(int arr[]int kint nint pos ksmall=arr[ ]ifor( = + ; < ; ++if(arr[ ]smallsmall arr[ ]pos ireturn posvoid selection_sort(int arr[],int nint kpostempfor( = ; < ; ++pos smal... |
24,649 | howeverin case the values are not equal then depending on the comparisonthe remaining search space is reduced to the part before or after the estimated position thuswe see that interpolation search is similar to the binary search technique howeverthe important difference between the two techniques is that binary search... |
24,650 | data structures using high mid else low mid return - int main(int arr[max]invalposclrscr()printf("\ enter the number of elements in the array ")scanf("% "& )printf("\ enter the elements ")for( <ni++scanf("% "&arr[ ])printf("\ enter the value to be searched ")scanf("% "&val)pos interpolation_search(arr - val)if(pos =- p... |
24,651 | jump_search (alower_boundupper_boundvalnstep [initializeset step sqrt( ) low lower_boundhigh upper_boundpos - step repeat step while step step if val [stepset high step else set low step [end of ifset [end of loopstep set low step repeat step while <high step if [ival pos print pos go to step [end of ifset [end of loop... |
24,652 | data structures using searching can start from somewhere middle in the list rather than from the beginning to optimize performance we can also improve the performance of jump search algorithm by repeatedly applying jump search for exampleif the size of the list is , , (nthe jump interval would then be = noweven the ide... |
24,653 | if(pos =- printf("\ % is not found in the array"val)else printf("\ % is found at position % "valpos)getche()return fibonacci search we are all well aware of the fibonacci series in which the first two terms are and and then each successive term is the sum of previous two terms in the fibonacci series given beloweach nu... |
24,654 | data structures using in librarythe information about books can be sorted alphabetically based on titles and then by authorsnames customersaddresses can be sorted based on the name of the city and then the street note data records can be sorted based on property such component or property is called sort key sort key ca... |
24,655 | in ascending orderin bubble sortingconsecutive adjacent pairs of elements in the array are compared with each other if the element at the lower index is greater than the element at the higher indexthe two elements are interchanged so that the element is placed before the bigger one this process will continue till the l... |
24,656 | data structures using (fcompare and since swapping is done observe that after the end of the second passthe second largest element is placed at the second highest index of the array all the other elements are still unsorted pass (acompare and since no swapping is done (bcompare and since no swapping is done (ccompare a... |
24,657 | complexity of bubble sort the complexity of any sorting algorithm depends upon the number of comparisons in bubble sortwe have seen that there are - passes in total in the first passn- comparisons are made to place the highest element in its correct position thenin pass there are - comparisons and the second highest el... |
24,658 | data structures using passes but we still have to continue with rest of the passes so once we have detected that the array is sortedthe algorithm must not be executed further this is the optimization over the original bubble sort algorithm in order to stop the execution of further passes after the array is sortedwe can... |
24,659 | example consider an array of integers given below we will sort the values in the array using insertion sort solution ais the only element in sorted list (pass (pass (pass (pass (pass sorted (pass (pass (pass (pass unsorted initiallya[ is the only element in the sorted set in pass [ will be placed either before or after... |
24,660 | data structures using advantages of insertion sort the advantages of this sorting algorithm are as followsit is easy to implement and efficient to use on small sets of data it can be efficiently implemented on data sets that are already substantially sorted it performs better than algorithms like selection sort and bub... |
24,661 | more complicated algorithms in certain situations selection sort is generally used for sorting files with very large objects (recordsand small keys technique consider an array arr with elements selection sort works as followsfirst find the smallest value in the array and place it in the first position thenfind the seco... |
24,662 | data structures using thusn- comparisons are required in the first pass thenthe smallest value is swapped with the element in the first position in pass selecting the second smallest value requires scanning the remaining elements and so on therefore( ( ( ( comparisons advantages of selection sort it is simple and easy ... |
24,663 | arr[karr[pos]arr[postemp merge sort merge sort is sorting algorithm that uses the divideconquerand combine algorithmic paradigm divide means partitioning the -element array to be sorted into two sub-arrays of / elements if is an array containing zero or one elementthen it is already sorted howeverif there are more elem... |
24,664 | data structures using compare arr[iand arr[ ]the smaller of the two is placed in temp at the location specified by index and subsequently the value or is incremented beg beg beg beg mid mid mid imid temp index end end end end imid beg end mid beg index index index index index end when is greater than midcopy the remain... |
24,665 | complexity of merge sort merge_sort(arrbegendstep if beg end set mid (beg end)/ call merge_sort (arrbegmidcall merge_sort (arrmid endmerge (arrbegmidend[end of ifstep end figure the running time of merge sort in the average case and the worst case can be given as ( log nalthough merge sort has an optimal time complexit... |
24,666 | data structures using temp[indexarr[ ] ++index++else while( <=midtemp[indexarr[ ] ++index++for( =beg; <index; ++arr[ktemp[ ]void merge_sort(int arr[]int begint endint midif(beg<endmid (beg+end)/ merge_sort(arrbegmid)merge_sort(arrmid+ end)merge(arrbegmidend) quick sort quick sort is widely used sorting algorithm develo... |
24,667 | technique quick sort works as follows set the index of the first element in the array to loc and left variables alsoset the index of the last element of the array to the right variable that isloc left and right - (where in the number of elements in the array start from the element pointed by right and scan the array fr... |
24,668 | data structures using since [loca[right]interchange the two values and set loc right start scanning from left to right since [loca[left]increment the value of left left right loc right loc left now left locso the procedure terminatesas the pivot element (the first element of the arraythat is is placed in its correct po... |
24,669 | complexity of quick sort in the average casethe running time of quick sort can be given as ( log nthe partitioning of the array which simply loops over the elements of the array once uses (ntime in the best caseevery time we partition the arraywe divide the list into two nearly equal pieces that isthe recursive call pr... |
24,670 | data structures using if(loc==rightflag = else if( [loc]> [right]temp [loc] [loca[right] [righttemploc rightif(flag!= while(( [loc> [left]&(loc!=left)left++if(loc==leftflag = else if( [loc< [left]temp [loc] [loca[left] [lefttemploc leftreturn locvoid quick_sort(int []int begint endint locif(beg<endloc partition(abegend... |
24,671 | algorithm for radixsort (arrnstep find the largest number in arr as large step [initializeset nop number of digits in large step set pass step repeat step while pass <nop- step set and initialize buckets step repeat steps to while < - step set digit digit at passth place in [istep add [ito the bucket numbered digit ste... |
24,672 | data structures using in the third passthe numbers are sorted according to the digit at the hundreds place the buckets are pictured upside down number the numbers are collected bucket by bucket the new list thus formed is the final sorted result after the third passthe list can be given as complexity of radix sort to c... |
24,673 | int arr[size]inprintf("\ enter the number of elements in the array")scanf("% "& )printf("\ enter the elements of the array")for( = ; < ; ++scanf("% "&arr[ ])radix_sort(arrn)printf("\ the sorted array is\ ")for( = ; < ; ++printf(% \ "arr[ ])getch()int largest(int arr[]int nint large=arr[ ]ifor( = ; < ; ++if(arr[ ]>large... |
24,674 | data structures using heapsort(arrn heap sort we have discussed binary heaps in thereforewe already know how to build heap from an arrayhow to insert new element in an already existing heapand how to delete an element from nowusing these basic conceptswe will discuss the application of heaps to write an efficient algor... |
24,675 | void restoreheapup(int *,int)void restoreheapdown(int*,int,int)int main(int heap[max], , ,jclrscr()printf("\ enter the number of elements ")scanf("% ",& )printf("\ enter the elements ")for( = ; <= ; ++scanf("% ",&heap[ ])restoreheapup(heapi)/heapify /delete the root element and heapify the heap =nfor( = ; <= ; ++int te... |
24,676 | data structures using shell sort shell sortinvented by donald shell in is sorting algorithm that is generalization of insertion sort while discussing insertion sortwe have observed two thingsfirstinsertion sort works well when the input data is 'almost sortedsecondinsertion sort is quite inefficient to use as it moves ... |
24,677 | result the elements of the array can be given as finallyarrange the elements of the array in single column and sort the column result finallythe elements of the array can be given as the algorithm to sort an array of elements using shell sort is shown in fig in the algorithmwe sort the elements of the array arr in mult... |
24,678 | data structures using programming example write program to implement shell sort algorithm #include void main(int arr[ ]={- }int ijnflag gap_sizetempprintf("\ enter the number of elements in the array")scanf("% "& )printf("\ enter % numbers", )/ was added for( = ; < ; ++scanf("% "&arr[ ])gap_size nwhile(flag = |gap_size... |
24,679 | programming example write program to implement tree sort algorithm #include #include #include struct tree struct tree *leftint numstruct tree *rightvoid insert (struct tree **int)void inorder (struct tree *)void mainstruct tree * int arr[ ]int clrscrprintf("\ enter elements ")for( = ; < ; ++scanf("% "&arr[ ]) null prin... |
24,680 | data structures using comparison of sorting algorithms table comparison of algorithms algorithm average case ( worst case ( selection sort ( ko( ( ko( insertion sort ( ( shell sort ( log nmerge sort ( log no( log nheap sort ( log nquick sort ( log no( log no( bubble sort bucket sort table compares the average-case and ... |
24,681 | in the above examplea single-pass merge was used but if the ratio of data to be sorted and available ram is particularly largea multi-pass sorting is used we can first merge only the first half of the sorted chunksthen the other halfand finally merge the two sorted chunks the exact number of passes depends on the follo... |
24,682 | data structures using exercises review questions which technique of searching an element in an array would you prefer to use and in which situation define sorting what is the importance of sorting what are the different types of sorting techniqueswhich sorting technique has the least worst case explain the difference b... |
24,683 | multiple-choice questions the worst case complexity is when compared with the average case complexity of binary search algorithm (aequal (bgreater (cless (dnone of these the complexity of binary search algorithm is (ao( (bo( (co( log (do(log which of the following cases occurs when searching an array using linear searc... |
24,684 | hashing and collision learning objective in this we will discuss another data structure known as hash table we will see what hash table is and why do we prefer hash tables over simple arrays we will also discuss hash functionscollisionsand the techniques to resolve collisions introduction in we discussed two search alg... |
24,685 | let us assume that the same company uses five-digit emp_id as the primary key in this casekey values will range from to if we want to use the same technique as abovewe need an array of size , of which only elements will be used this is illustrated in fig key array of employeesrecords key employee record with emp_id [ k... |
24,686 | data structures using is said to occur similarlykeys and also collide the main goal of using hash function is to reduce the range of array indices that have to be handled thusinstead of having valueswe just need valuesthereby reducing the amount of storage space required universe of keys ( actual keys ( figure actual k... |
24,687 | on external variable parameters (such as the time of dayand on the memory address of the object being hashed (because address of the object may change during processinguniformity good hash function must map the keys as evenly as possible over its output range this means that the probability of generating every hash val... |
24,688 | data structures using step multiply the key by step extract the fractional part of ka step multiply the result of step by the size of hash table (mhencethe hash function can be given ash(ki (ka mod where (ka mod gives the fractional part of ka and is the total number of indices in the hash table the greatest advantage ... |
24,689 | step add the individual parts that isobtain the sum of kn the hash value is produced by ignoring the last carryif any note that the number of digits in each part of the key will vary depending upon the size of the hash table for exampleif the hash table has size of then there are locations in the hash table to address ... |
24,690 | data structures using where is the size of the hash tablehc/( ( mod )and is the probe number that varies from to - thereforefor given key kfirst the location generated by [hc/(kmod mis probed because for the first time = if the location is freethe value is stored in itelse the second probe generates the address of the ... |
24,691 | ( mod = since [ is vacantinsert key at this location - step - - - - - - - - - key ( ( mod mod ( mod since [ is vacantinsert key at this location - - - step key ( ( mod mod ( mod = since [ is vacantinsert key at this location - step key ( ( mod mod ( mod = now [ is occupiedso we cannot store the key in [ thereforetry ag... |
24,692 | data structures using - - - step key ( ( mod mod ( mod = now [ is occupiedso we cannot store the key in [ thereforetry again for the next location thus probei this time key ( ( mod mod ( mod = [ is also occupiedso we cannot store the key in this location the procedure will be repeated until the hash function generates ... |
24,693 | probes that are required to find free location and lesser is the performance this phenomenon is called primary clustering to avoid primary clusteringother techniques such as quadratic probing and double hashing are used quadratic probing in this techniqueif value is already stored at location generated by ( )then the f... |
24,694 | data structures using step key ( [ mod mod [ mod mod mod = since [ is vacantinsert the key in [ the hash table now becomes - - - - - - - step key ( [ mod mod [ mod mod mod = since [ is vacantinsert the key in [ the hash table now becomes - - - - - - step key ( [ mod mod [ mod mod mod = since [ is vacantinsert the key i... |
24,695 | [ mod mod [ mod mod [ mod mod = since [ is vacantinsert the key in [ the hash table now becomes - - - searching value using quadratic probing while searching value using the quadratic probing techniquethe array index is re-computed and the key of the element stored at that location is compared with the value that has t... |
24,696 | data structures using hence the name double hashing in double hashingwe use two hash functions rather than single function the hash function in the case of double hashing can be given ash(ki[ (kih ( )mod where is the size of the hash tableh (kand (kare two hash functions given as (kk mod mh (kk mod ' is the probe numbe... |
24,697 | step key ( [ mod ( mod )mod [ ( )mod mod = since [ is vacantinsert the key in [ the hash table now becomes - - - - - - - step key ( [ mod ( mod )mod [ ( )mod mod = since [ is vacantinsert the key in [ the hash table now becomes - - - - - - step key ( [ mod ( mod )mod [ ( )mod mod = since [ is vacantinsert the key in [ ... |
24,698 | data structures using [ ( )mod ( mod mod = now [ is occupiedso we cannot store the key in [ thereforetry again for the next location thus probei this time key ( [ mod ( mod )mod [ ( )mod [ mod mod = since [ is vacantinsert the key in [ the hash table now becomes - - - step key ( [ mod ( mod )mod [ ( )mod mod = now [ is... |
24,699 | note that the new hash table is of locationsdouble the size of the original table nowrehash the key values from the old hash table into the new one using hash function-- (xx programming example write program to show searching using closed hashing #include #include int ht[ ]ifound keyvoid insert_val()void search_val()vo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.