Download as pdf
Download as pdf
You are on page 1of 4
CSN -102 -LEARNING REPORT NAME -AMAN LACHHIRAMKA ENROLLMENT NO-21116013 BATCH NO.-05, ECE In this CSN-102 course, | have leaned about linear and non-linear data structures, Linear data structures include Atrays, Lists, Stacks, and Queries, and Nonlinear data structures Trees, and Graphs data structures which further have their Adapted Data Structures: Linked List (Doubly, Circular), Queue (Priority), Trees (Binary, Segment), Heap (Leftist), Binary Search-Trees (AVL, Red-Black). Graphs (Undirected, DAG, Bipartte. ARRAYS ‘Arrays are used to store and manipulate multiple values of the same data type in a properly organized and orderly manner stored at contiguous memory locations which makes our task very easy to determine the location of each element by simply adding an offset to a base value (fist element). ‘Arrays are used in implementing other data structures like queues, tees like binary trees (as arrays are easier to handle because no of children is fixed ), stacks, and merging operations in heap sorting. In graphs, arrays are used in form of an adjacency matrix where vertex labels [0, n-1] and edges are sorted using a 2D matrix In day to day applications, arrays can be used in logging data of entry and exit timings of employees in a building, ‘Arrays also finds alot of uses infield of data science. We can store mobile numbers and contact name in a 2D array where we perform search operations to find the name or number ‘Suppose we ate required to create a dataset of prices of books in a store, we can easily sort them using multiple sorting ‘operations of arrays whiich we have learned in this course like bubble, selection, insertion, radix or bucket sort. Also if we want to find the costliest or cheapest phone we can easily do that very easily. If we had not chosen an array, we have to declare variables for each which would make the data handling cumbersome. ‘Adapted versions of the arrays can be seen in queues, graphs, trees and stacks and we can implement all these DS using arrays operations such push, pop, enqueue, dequeue and in binary trees. Some disadvantages of using arrays are its static length-its size can’t be changed as the users are giving the inputs, homogenous storage of data. Insertion and deletion of elements are also relatively time complex. Also we cannot store data in hierarchical order LINKED LISTS ‘There are many drawoacks of using arrays and it can be difficult sometimes to store data inthe array if continuous memory is not available. Time complexities of insertion and deletion operations in arrays are more. On the contraty, linked lists are dynamic and have faster insertion/deletion time complexities. Unlike an array, elements during a linked list aren’t in consecutive memory locations ‘A Linked list can be used in graphs where adjacency list representation of graphs uses a linked list to store adjacent vertices A linear data structure is known as a "doubly linked list” (DLL) has the same data and a second pointer, sometimes referred to as the “previous pointer,” as in a singly linked list. A doubly linked lists function is to allow non-contiguous memory storage while still enabling both-way traversal. Doubly linked lists have the advantages of bidirectional traversal and simpler deletion over singly-linked list, Implementations or applications of DLL are Undo/redo functionality, forward and backward navigation of visited web pages, and other navigation systems where front and back navigation is required ‘A browser cache that allows you to move between pages is also a good example of a double-linked list Unlike arrays, which are stored in contiguous memory and allow for the insertion of elements anywhere inthe list, Circular linked lists allow forthe insertion of elements at any point inthe list. The previous element in a circular linked list stores the address of the next element, and the last element stores the address of the starting element Real-time implementation of CLL is Multiplayer games where all players are kept in a Circular Linked List and the pointer continually moving forward as a players chance finishes, Al the running programs are kept in circular linked list and the OS assigns each player a fixed slot of time to play. Linked lists don't require a predefined size and can allocate or release memory on the fly. As the linked lists size Changes while itis running, memory is used. However, since linked lists also allocate memory for pointers, extra memory is needed. Its impossible to access an element at random. STACKS ‘Stacks are data structures that work on the principle of LIFO which is last in first out. To remove or add an element to @ stack we can take the help of push or pop functions. We have seen a lot of infix and postfix problems in this course and use of stacks was essentially based on the fact that they can be easily and quickly used to add elements to the top and remove from the top and stacks are found so helpful where we were required to access the last element. We can continu to push elements in the stack till we need to access them. ‘Some of the implementations of using stacks are: Stacks can be used for backtracking, orto verify if an expression’s parenthesis match. It can also be used to change the expression from one form to anather. It can be applied to formally manage memoria. | think onacreal-lifl life implementation can also be displaying news where the latest news are displayed while keens keep getting added to the stack. Some more implementations are the phone answering system and ticket booking system ‘stacks don't corrupt readily, making them more dependable and secure. Memory allocation and deallocation are made simple, But because stack memory is predetermined, its capacity is constrained. In excess of this size, a stack overflow occurs. Itis impossible to access an element at random. Element inserting ina stack is very difficult as we have to pop, insert and then again push, Too meny objects may lead to stack overflow because it has a fixed size, Stacks have contiguous ‘memory, and insertion and deletion are O(2) operations. Stacks are of limited size, and its size must be defined beforehand. In stacks, random access is not feasible, On the other hand, stacks clean up automatically. QUEUES The queue isa linear structure that follows a particular order in which the operations are performed following FIFO(Fitst in and first out) order. ‘Queue can be graphically represented in a similar way to @ list or stack, but with an additional two cell in which the first element points to the front of the list of all the elements in the queue and second element points to the last element of the list. Itcan be implemented using an array (or a circular array) COnly a small number of elements can be organized by a queue constructed using an array. A linked list can also be used to implement it, An infinite number of elements factors arranged using a linked list queue. ADT may contain enqueve(), dequeved, ete, ‘Some of the real life implementations of Queues include busfticketelevator, CPU schediling and Printer scheduling ete. It can be used to find no of siblings of a given node in a binary tree and implemented BFS in a graph ‘Applications that serve multiple users often employ queues because they can effectively handle enormous amounts of data, In the end, insertion and deletion are simple to complete, However, inserting and deleting at the center of an array is more difficult. ts maximum size should also be predetermined. Random access to the elements or indices is not allowed in queues, therefore, insertion-deletion is difficult, and just like stacks due to their fixed size it gives an overflow error. Priority queues are special type of queues where the order of entering in the queve is not the factor but rather we have a ‘well-defined priority value the order in which they will be popped. ‘Some excellent examples of Priority queues were discussed in the class such as airport check-in counters prioritizing first-class customers. The scheduling of requests for a single shared resource, such as a disc or CPU, interruptions caused by real-time or hardware systems handling website traffic, switches and routers in networking, and maintaining the playlist in media players are some other real-world applications for queue. Doubly ended queues-In this type of queue, the elements can be added or deleted from either end. ‘Queue has fixed size thus overflow or underflow may occur. Enqueue and Dequeue operations can be performed efficiently that is in O(1) time, One of the drawback of the queue is that we can’t insert between easily and also max. size of queue is predefined TREES ‘Aree can be defined as either the empty tree or a node with alist of successor trees. Nodes are usually, though not always labeled with a data item. We refer to the label of a nade as its value. Trees area type of data structure where each node has @ unique parent but can have multiple children. To access a node we have to move across all parents nodes because trees can only store hierarchical data Trees can be used to solve an arithmetic expression by sorting operands and operators in form of tree and DFS of it dives the solution. inary search trees can be used to find whether a no exist in given set of data or not ina relatively efficient time. Proper working and efficiency of BSTS are maintained only due to maintaining balance of them and keeping the worst-case time complexity to a max of logarithm of the number of elements of the BST ‘Trees can be implemented in situations of hierarchy or network lke decision making algorithms, databases etc. In data compression, Huffman coding is used to create a binary tree capable of compressing data, HashMap uses Red-Black trees instead of LinkedlList to store different elements with colliding hash codes. Trees are also used to store the location of routers based on their IP addresses where routers with similar addresses are grouped under a single tree, ‘A real-life implementation of trees can be a delivery system where a customer order some goods anywhere in the Country could be tackled using trees asthe target location, roads, towns, etc are forming a hierarchical order ‘Segment Trees can be used to solve Range Min/Max & Sum Queries and Range Update Queries in © (log n) time where a segment tree is date structure that allows answering range queries over an array effectively, while still being flexible enough to allow modifying the array. ‘Trees are used to store only hierarchical data and to access a node we have to move across all the parent nodes. Also Minimum spanning tree has high time complexity in cases with a no of edges with same weight and also itis limited to graph. ‘Therefore trees are very acvantageous in many respects as they help reduce the time complexity in many examples although there are also some issues related to its storage HEAPS Heaps are data structure like binary trees, but here the value of a node must be greater thn their parents and les than their child nodes for min-heap and opposite inthe case of max-heap In heaps, the idea is thatthe node labels, which were the search keys when talking about binary search trees are now ‘numbers representing the priority of each item in a question. Heaps can be implemented using arrays due to easy relation among parent-child indexes. ADT includes reportmin(, deletemind, insert() ete. Essential implementation of heaps is done through binary trees. It is used in the heap sort algorithm, | have learned how much heaps are necessary for algorithms that require reporting of minimum or maximum while also updating as shown inthe question in class. | have chosen heap on the basis of its easy access of elements and easy insertion and deletion, (One ofthe most important operations we have seen isthe merge or meld operation in heaps which can be used in deletion, insertion. Itis also used for finding order in statistics. ‘Systems concerned with security and embedded system such as LINUX KERNEL uses Heap sort because ofthe O(nlog(n)). ‘A piriority queue that uses a certain kind of binary heap is called a leftist heap. A leftist tree may be quite unbalanced, in contrast to a binary heap (which is always a complete binary tree). Leftist heaps adhere to the rule that dist(right()) ist(left(i)) and key(oarent(i) =key(i), where dist) isthe number of edges on the shortest path from node Ito a leaf node, respectively. Leftist heaps can tackle many issues related where accessing elements on one side can be easier and other side skewness holds no value Since there is no relative ordering among the items of a heap, unlike ina binary search tree, it is useless when trying to tly search for a key. GRAPHS Graphs are non linear DS consisting of nodes and edges which can connect any two nodes in graph Graphs can also be implemented just like trees using pointers or vectors. ‘Adjacency Matrix (using arrays), Adjacency List (using linked lists), and edge List can all be used to create graphs. A ‘new, empty graph can be created with the commands Graph (), Add Vertex(vert), and AddEdge (fromVert,toVert), | earned about graph traversals and two types of traversals which have their different implementations: DFS and BFS. | earned about directed graphs which are graphs having a unique path or relation between two node. All these have a lot of real life implementation in our day to day life finding mutual friends on facebook and followers on Instagram, | also got to know about Minimum spanning tree which can be used to make transportation system and computer networks. Graphs in form of DAG is used by crypto makers as an alternative to blockchain for cryptocurrency ‘Shortest path trees are weighted graphs consisting of shorted path between nodes or to calculate the shorted sum of distance to reach a node from a node. This find an important implementation in real world in GPS system where we can find the shortest distance between two locations and minimizing travelling and transportation costs. ‘The “source node" is one of the nodes that Dijksta’s Algorithm uses to determine the shortest route between that node and every other node in the graph. In order to determine the path that minimises the overall distance (weight) between the source nade and all other nodes, this technique uses the edge weights, A subset of edges in a weighted linked graph that connects al ofthe vertices with the least amount of edge weight and without any cycles is known as a Minimum Spanning Tree (MST). Prim’s algorithm or Kruskal's algorithm can be used to derive an MST. ‘A graph method is completely dynamic if it can handle edge insertions and deletions as well as both; it is only incremental if it supports insertions and only decremental if it supports only deletions. (One disadvantage of using graphs is that it uses a lot of pointers which are difficult to handle and can also have large memory complexity. Also, sometimes it becomes difficult to comprehend, CONCLUSION ‘The course taught me how a difficult to difficult DSA problem or its application based real life problems can be solved using concepts of different data structures or their adapter versions in a very interesting manner easily. You just need to know about the details of each data structures and should able to identify the DS going to be used in the problem based on the requirement of the problem. The real life implementation are very interesting and helped me improve my problem solving and logical reasoning skills, | also learned about tweaking the properties of data structures to our benefits

You might also like