Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Student Name: Lekshmi Sreekumaran Course: MSc IT Registration Number: 1405004603 LC Code: 00097 Subject Name: DATA & FILE STRUCTURES Subject Code: MIT102 1. Define data structure? Explain different types of data structures. In computer science, a data structure is a particular way of organizing data in a computer so that it can be used efficiently. Data Structure Non Linear Linear Array Stack Queue Linked List Trees Graphs Files Linear Data structure : Data is stored in linear or sequential form. Arrays : Array is a collection of homogeneous type of elements. Eg : int number[] = { 1,2,3,4,22} Element1 Element 2 Element3 Stack : It is a linear list in which insertions and deletions are restricted at one end, called top of stack. It contains 2 operations push and pop. Also called last in first out(LIFO) as the element pushed last will be popped out first. 1 Queue: It is a linear list in which insertion and deletion takes place at different ends. End where we insert is called the rear end and deletion at front end. Also called First in First out(FIFO). Linked List : Linked list consists of a series of nodes . Each node contains the 2 parts: Data field(contains data) and Link field(contains address of next node). Non Linear Data Structure : Data is stored in dispersed or non-sequential order. Trees: Trees is a nonlinear data structure which contains the hierarchical relationship between various elements. The top node of a tree is called root. As a data type, a tree has a value and children, and the children are themselves trees; the value and children of the tree are interpreted as the value of the root node and the subtrees of the children of the root node. Graph : Data sometimes contains relationship between pairs of elementswhich is necessarily hierarchical in nature. 2. Write short notes on: a) Doubly linked list b) Circular linked list Double link list : Link list with two link field one to point the next field and other to point the previous field . It is also called two way list. The two node links allow traversal of the list in either direction. While adding or removing a node in a doubly-linked list requires changing more links than the same operations on a singly linked list, the operations are simpler and potentially more efficient (for 2 nodes other than first nodes) because there is no need to keep track of the previous node during traversal or no need to traverse the list to find the previous node, so that its link can be modified. Circular Linked List : Circular linked list is the one where the null pointer in the last node is replaced with address of first node so that it forms a circle. The advantage of this implementation is easy accessibility of nodes i.e. every node is accessible from a given node. This often allows us to avoid storing firstNode and lastNode, although if the list may be empty we need a special representation for the empty list, such as a lastNode variable which points to some node in the list or is null if it's empty; we use such a lastNode here. This representation significantly simplifies adding and removing nodes with a non-empty list. It can be implemented both in one way list or two way list. Elements can be added to the back of the list and removed from the front in constant time. 3. List the Advantages and Disadvantages of Linear and linked representation of tree. Advantages of linear representation of binary tree 1) Node can be accessed directly with the help of the index through which we can improve the efficiency of execution time of an algorithm. 2) Data are stored without pointer reference of successor or predecessor 3) This representation is very much useful where the language does not support the dynamic memory allocation. Disadvantages of Linear representation of binary tree 1) Memory is wasted here because it will be allocated for all the nodes absence of node will leads to empty entries in array. 2) Since the array size is limited enhancement of tree structure is restricted. 3) Inefficiency in processing time during insertion or deletion of nodes because considerable movement of up and down is taking place in array structure. 3 Advantages of linked representation of binary tree 1) Utilization of memory is efficient. 2) Enhancement of tree is possible in this representation. 3) Insertion and deletion of nodes can be easily handled with the pointers without data movement. Disadvantages of linked representation of tree 1) It is difficult to implement with the language which does not support the dynamic allocation of memory. 2) Since pointer is involved for data reference it occupies more memory. 4. List and explain any Five types of graph. Directed Graph : The edges of a graph provide the connections between one node and another. By default, an edge is assumed to be bidirectional. That is, if there exists an edge between nodes vand u, it is assumed that one can travel from v to u and from u to v. Graphs with bidirectional edges are said to be undirected graphs, because there is no implicit direction in their edges. Undirected Graph : An edge might infer a one-way connection from one node to another. For example, when modeling the Internet as a graph, a hyperlink from Web page v linking to Web page u would imply that the edge between v to u would be unidirectional. That is, that one could navigate from v to u, but not from u to v. Graphs that use unidirectional edges are said to be directed graphs. Weighed Graph : The graph is called Weighted Graph, if information like cost or weight is associated to the traversal of an edge. Directed and undirected graphs may both be weighted. The operations on a weighted graph are the same with addition of a weight parameter during edge creation. Weighted Graph operation is the extension of Undirected or Directed graph operation. Multigraph : multigraph is a graph which has more than one edge between the same two vertices. For example, if one were modeling airline flights, there might be multiple flights between two cities, occurring at different times of the day. When we want to distinguish between different nodes and edges then we can associate labels with each nodes and edges. If a label is associated with each nodes and edges in a graph then such a graph is said to be labeled. Strongly connected graph : A directed graph is called strongly connected if there is a path in each direction between each pair of vertices of the graph. In a directed graph G that may not itself be strongly 4 connected, a pair of vertices u and v are said to be strongly connected to each other if there is a path in each direction between them. 5. Explain 1. Fixed block storage allocation. 2. Variable block storage allocation. Fixed Block storage allocation : Fixed block storage allocation is the simplest case of dynamic storage allocation. This is the straight forward method in which, all the blocks are of identical in size. The user can decide the size of the block. The operating system keeps a pointer called AVAIL. This pointer points to memory. A user program communicates with the memory manager by means of two functions GETNODE(NODE) and RETURNNODE (ptr). GETNODE() procedure is used to avail an free node from the AVAIL list whereas the RETURNNODE() is used to return the block of memory, whenever a memory block is no longer required. Whenever the GETNODE() is executed it checks for the availability of free node in the AVAIL list and get a memory block from the AVAIL list Procedure RETURNNODE() used to return back the used memory to the AVAIL list. So far as the implementation of fixed block allocation is concerned, this is the simplest strategy. But main drawback of this strategy is the wastage of space. For example, suppose each memory block is of size 1k (1024 bytes); now for a request of a memory block, say, of size 1.1k we have to avail 2 blocks (that is 2k memory space), thus wasting 0.9k memory space. Making the size of the block too small reduces the wastage of space; however, it also reduces the overall performance of the scheme. Variable block storage : Blocks of variable sizes are used for storage . Here also linked lists play a vital for the management of memory blocks. Variable Block storage involves using algorithms to determine a variable block size. The data is split based on the algorithm’s determination. Then, those blocks are stored in the subsystem. Consider a procedure that assumes the blocks of memory are stored in ascending order of their sizes. The node structure maintains a field to store the size of the block, namely SIZE. SIZEOF() is a method that will return the size of the node. The above procedure initially check for the NULL status of AVAIL list and proceeds with the search for the exact size of block which is requested and return the same, if the pool does not have the requested size it will return the bigger size of block. Procedure RETURNNODE() will return the used block of memory to the memory pool. While returning unless like fixed block, it searches for the size the existing pool where it can be inserted. Because we assume that the free pool memory blocks are arranged in ascending order. So while returning, procedure will find the place according the size of the returning block and the same will be inserted into the memory pool. 6. What is the use of external Storage Devices? Explain any two external storage devices. External storage devices are used to Store data even when the computer is turned off so the data data can be used whenever needed. Backup or overlay of program during execution. Storage of programs, subprograms and data. Storage of information in files. Hard Disk 5 Surfaces of diskettes and magnetic tape are all coated with a magnetically sensitive material such as iron oxide. The principle use to store data is that of polarization – all the ions in the magnetic material align themselves in one direction. Just as a transistor can represent binary “on” or “off”, the orientation of the magnetic field can be used to represent data. Hard disk is still the most common storage device for all computers. Hard drives store data in tracks divided into sectors. Includes one or more metal platters mounted on a central spindle, like a stack of rigid diskettes. Each platter is covered with a metal coating and the entire unit is contained in a sealed chamber. The hard disk and drive are a single unit which includes the hard disk, the motor that spins the platters and a set of read/write heads. Because you cannot remove the disk from the drive the terms hard disk and hard drive are used interchangeably. Hard drives have become the primary storage devices for PCs because they are convenient and cost effective. They outperform diskettes in both speed and capacity. Hard disks offer capacities from several hundred MB and more. Optical Storage Devices The most popular alternative to magnetic storage systems are optical storage media. The most widely used type of optical storage medium is the compact disk (CD), which is used in CDROM, DVD-ROM, CDR, CDRW and PhotoCD systems. Since the mid 1990s nearly all PCs have been sold with a built in CD-ROM drive. These devices fall into the optical storage category because they store data on a reflective surface so that it can be read by a beam of laser light. A laser uses concentrated, narrow beam of light, focused and directed with lenses, prisms and mirrors. The tight focus of the laser beam is possible because all the light is of the same wavelength. 6