Tuesday, June 4, 2019

An Overview Algorithms And Data Structures Computer Science Essay

An Overview Algorithms And Data Structures figurer Science EssayAlgorithms brood of a mark of rules to execute calculations by hand or machine. It underside also be defined as an abstraction consisting a program executed on a machine (Drozdek 2004). This program will follow carrying bulge outs carried out in sequence on data organized in data social organizations. These data structures atomic look 18 gener completelyy categorized intoLinear data structures examples which ar arrays, matrices, chop uped array trees and united heed among others.The tree data structures which include binary tree, binary inquisition tree, B- trees, give e.t.c.Hashes which consist of the commonly used hash tableGraphGraphThis is an abstract data structure which implements the graph oriented concepts. The graph will consist of arcs or edges as (x, y) of nodes or vertices. The edges may assume some value or numeric attribute much(prenominal) as cost length or capacity. Some of the operations o f the graph structure G would includeAdjacent (x, y) an operation testing whether for the existence of an edge between x and y.Set_ node, value (G x, a) an operation setting the value associated with node x to aAdd (G x, y) an operation that adds to the graph an arc from x and y if it is not existent.Graph algorithms be implement within computer science to find the pathways between two nodes like the depth or comprehensiveness first bet or the shortest path (Sedgewick 2001 p 253). This is implemented by the Dijkstras algorithm. The Floyd Warshall algorithm is used to derive the shortest path between nodes.Linked listsThese are linear data structures consisting of a data sequence linked by a reference. Linked lists provide implementation for stacks, queues, skip lists and hash tables. Linked lists are preferred over arrays because the lists may be ordered otherwise from how they are stored in memory. These lists will t here(predicate)fore allow the removal or insertion of no des at any point. Each component or record has a node containing an address to the next node called the pointer or next link. The remainder of the fields are known as the payload, cargo, data or information. The list has first node as the head and the brook node as the tail. A linked list may be circularly linked where the last node references the first node in the same list or linear where the link field is open.B - guideThis is a tree data structure that stores miened data and allows searches, deletions, insertions and sequential access. The operations in the B- Tree are normally optimized for bulky data systems. The B -Tree has variants of jut out. However the B -Tree stores keys in the intragroup nodes. However this does not normally reflect at the leaves. The general variations are B+ Tree and B* Tree (Comer 129).The searching process is similar for the B- Tree and the binary search tree. It commences at the root and a traversal is executed from top to bottom. The search points at the child pointer with values between the search values. The insertion starts at the leaf node which if containing fewer than legally acceptable elements qualify for an sum total, otherwise the node is evenly split into two nodes. A normal is chosen in determining the left or justifiedly hand placements with values greater than the median going to the right node. The median here acts as the separation value. The deletion process assumes two popular strategies. Either the element located is deleted followed by a easementructuring of the tree. Alternatively a scan may be performed followed by a restructuring of the tree after the candidate node to be delete has been identified.HashesThis is a data structure employing the hash function mapping to identity keys. The function transforms the key as an index of an array. The function then maps every key possibility to a unique slot index. Using well dimensioned hash tables every look up is independent of the population in th e array. The hash table efficiency is utilized in database indexing, implementation of sets and cache and associative arrays. A simple array is central to the hash table algorithm. This algorithm derives an index from the elements key. This index is then used to store the elements in the array. The hash function f represents the implementation of the calculation. Hash tables implement various types of memory tables. The keys are used in this case for persistent data structures and disk based database indices.Greedy Algorithms.These algorithms build by making most promising findings at the onset whatever the outcome would be is not taken into consideration at that moment. These algorithms are considered nifty forward, simple and short sighted (Chartrand 1984). The upside or advantage to these miserly algorithms is that they are easy to invent and implement and will prove efficient.Their disadvantage is that they are not able fusss optimally because of their greedy approach. Gree dy algorithms are applied when we try to solve optimization occupations.A typical implementation of these algorithms is the making agitate problem whereby we are required to give change using minimum number of notes or coins. We commence by giving the largest denomination first.Informally the greedy algorithm for this problem would follow the steps belowBegin without anythingAt each stage and without passing a given amount knock over the largest addition to the set.A formal algorithm of the implementation of the making change problem can be written as here belowMkChangeC 100, 25, 10, 5, 1 // C is a constant set of different coinage denominationsSol X // Represents the solution setSum 0 which is the sum of relics in X speckle Sum. Not = nL =Largest of C such thatSum +L IF no such item THENRETURN No itemSUM Sum+LRETURN S.An approach by the greedy algorithm to ensure optimization is the maintaining of two sets one for chosen items and the other for rejected items. Based on the two sets the algorithm will carry out four functions. Function one checks whether the chosen set of items can provide a solution. Function two checks for flexibility of the set. The selection function identifies the candidates. The objective function gives a solution.The greedy algorithm applies for the shortest path. The Dijkstras algorithm aims at determining the length of the shortest path. This path have a bun in the ovens from S the source to other nodes.Typically Dijkstras algorithm maintains two sets of nodes S and C. S in this case consists of already selected nodes whereas C will consist of the rest of the nodes within the graph (Papadimitrious Steiglitz 1998). At the initialization of the algorithm our set X has only S. After execution X includes all the nodes of the graph. During every step in the algorithm a node in C that is close-hauled to S is chosen. The remainder nodes that dont belong to S will result in a unconnected graph.The diagrams below illustrate the Dijkstr a algorithm makeing the graph G = (V, E). Each node of the graph has an infinite cost apart from the source node with 0 be (Design and Analysis of Computer Algorithms 2010)Source Design and Analysis of Computer Algorithms 2010Initialize dS to zero and choose the node closest to S. Add to S while restful all other nodes adjacent to S.Update every node. The diagram here below illustrates this processSource Design and Analysis of Computer Algorithms 2010Choose the closest node X and relax adjacent nodes while updating u, v and y as indicated in the diagram below.SourceNext we consider y as closest and add to S and relax V as indicated in the diagram belowSource Design and Analysis of Computer Algorithms 2010Consider u and adjust v as a neighbor as indicated in the diagram here below.Source Design and Analysis of Computer Algorithms 2010 in the long run add V and the predecessor list now defines the shortest path from S which was the source node. The diagram below illustrates the resul ting shortest pathSource Design and Analysis of Computer Algorithms 2010Spanning treesTypically graphs will have a number of paths between nodes. Spanning tree graphs consist of all the nodes with a path between any two nodes. A graph consists of different spanning trees. A disconnected graph will represent a spanning forest. A breadth first spanning tree results after a breadth first search on this graph. The depth first spanning tree results after a depth first search on the spanning tree. Spanning tree industriousnesss among others includes the travelling salesman problem here belowProblem Considering an undirected graph G= (V, E) having a non negative integer cost associated with every edge and representing a certain distance. We can derive a tour of the graph G with the minimum cost. The salesman may start from city 1 and go on to the six cities (1 6) and return gage to city 1.The first approach would run in the following manner from city1 to 4 to 2 to 5 to 6 to 3 to 1 resul ting in a total of 62 kilometers. The diagram below shows this approach.Adding the edge weights we have 15+10+8+15+9+5 = 62Source Design and Analysis of Computer Algorithms 2010The other alternative approach which is the most optimal would run in the following man from city 1 to 2 to 5 to 4 to 6 to 3 to 1 resulting in a total of 48 kilometers. The diagram below shows this approach.Adding the edge weights we have 10+8+8+8+9+5= 48 KilometersSource Design and Analysis of Computer Algorithms 2010Other applications using the panning tree approach are like the airlines route determination, designing of computer networks, the laying of oil pipelines to connect refineries and road link constructions between cities. (Goodrich Tamassia 2010 Sedgewick 2002).A typical minimum spanning tree application based on the spanning tree application MST(minimum spanning tree) cost can be used o determine the points of connection of some cable for example the type optic being laid along a certain path. The edges with a larger weight which corresponds to more cost would be those that require more caution and resources to lay the cable. An appropriate result would be derived from the graph with the minimum cost.Prims Algorithm.The approach for this algorithm is that it proceeds from an arbitrary root node at every stage. A new edge being added to the tree at every step. The addition process terminates when all the nodes in the graph have been achieved. This algorithm concentrates on the shortest edge. therefore the time lapse for the algorithm will depend on how the edge is searched. The straight forward search method identifies the smallest edge by searching adjacently a list of all nodes in the graph. Every search as an iteration has a cost time O (m). Total cost time to run a complete search is O (mn).The Prim algorithm (basic) takes the following stepsInitialize the tree to consist of a start nodeWHILE not all nodes in the treeLoopExamine all nodes in the graph with one end po int in the tree aim the shortest edge adding it to the treeEnd.After each step or iteration a partially completed spanning tree holding a maximum number of shortest edges is created as A and B will consist of the remaining nodes. The loop looks for the shortest edge between A and B.Kruskals Algorithm.This is an algorithm that computes the minimum spanning tree (MST). This is done by building a generic algorithm into a forest. Kruskals algorithm will consider every edge and is ordered based on the increasing weight. Consider an edge (u, v) that connecting two different trees. It follows that (u, v) will be added to the set of edges in the generic algorithm. The resultant is a single tree from two trees connected by (u, v).The algorithm can be outlined as followsCommence with an empty set E selecting at each stage the shortest edge not except chosen or discarded regardless of its location on the graphMST KRUSKAL (G, w)A // the set containing the edges of the MSTfor every node n in VGdo make_set (n)sort edge of E by decreasing weights wfor each edge (u, n) in Edo if FIND_SET (u) not equal FIND_SET (n)then A=A U (U, N)UNION (u, n)Return AThe algorithm above makes use of disjoint set data structures. Kruskals algorithm can also be implemented with the priority queue data structure. The resulting algorithm is shown belowMST KRUSKAL (G)for each node n in VG dodefine S(n) ninitialize the queue Q consisting of all the edges of the graph G. Weights are not used as key hereA // This set will contain the edges of the generic algorithm(MST)WHILE A has flying bomb edges don S(n) and u S(u)IF S (n) = S (u) Then add edge (u, n) to A S(n) U S(u)Return AThe Binary Search Tree.A binary tree is one where every internal node X will store an element. Generally the elements in the left sub tree of X are less than or equal to X whereas those on the right sub tree are equal or greater than X. This represents the binary search tree property. The binary search tree height amo unts to the number of links between the root and the deepest node (Skeinna 2008). The implementation of the binary search tree is such as a linked data structure where each node is an object with a total of three pointer fields namely left, right and raise. These points to nodes corresponding to the left, right children and the parent. A NIL in any of these fields indicates no parent or child. The root node contains NIL in the Parent field.Dynamic schedule algorithmsThese typically explores ways of optimization sequence based decisions in determining solutions. The algorithms employed avoid full enumeration of partial decisions that having a sub optimal contribution to the final solution. They instead concentrate only on optimal contributors (Aho Hopcrost 1983). The optimal solution is derived from a polynomial number of decision steps. At other times it is necessary for the algorithm to be fully implemented, however in most cases only the optimal solution is considered.Dynamic p rogramming algorithms use of duplication and every sub solution is stored for later referencing. These solutions to the sub problems are held in a table. The total sub problems are then worked out using the bottom up technique. The steps in this bottom up technique will include the followingBegin by addressing the smallest sub problemCombine and sum up their solution increasing the scope and sizeUNTIL arriving at the solution of the original problemDynamic programming relies on the tenet of optimality. This principle alludes to the fact that present in an optimal decision or choice sequences are sub sequences that must be optimal as well.Warshall Algorithm.The WFI algorithm as it is also known is a graph analysis algorithm used to determine the shortest path in a weighted graph (Chartrand 1984). A comparison carried out will cover all possible paths between nodes of the graph. Consider graph G with nodes V as 1 to N. Let sPath(i, j, k) be the function that will return the shortest path between I and j while using the nodes 1 to k, demonstrates a recursive formula that results as shown here belowsPath(i, j, k)= minshortestPath(I, j, k-1),shortestPath(i, j, k -1)+shortestPath(k, j, k-1)shortestPath(i, j, 0) = edgeCost(i, j)This forms the heart of the WFI algorithm. The shortest path is first computed as shortestPath(i, j, k) for all (i, j) pairs of k where k = 1 to n.The Floyd Warshall algorithm iteratively determine paths lengths between nodes (i, j) over i=j.The initial path is considered as zero, the algorithm provides the path lengths between the nodes.ConclusionData structures and their associated algorithms are fundamental even today in providing the way of life for data storage and manipulation (Sage 2006). Core and complex computer processing involving memory management functions for operating systems, the database management systems cache implementation rely on data structures and their associated algorithms to execute efficiently and effectively. It is therefore becomes necessary that an adequate study of these data structures and algorithms is carefully studied and understood by system programmers to ensure the design of efficient and effective software.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.