In order to succeed, we must first believe that we can.
--Your friends at LectureNotes

Note for Data Structure and Algorithms - DSA by Ajay Madheshi

  • Data Structure and Algorithms - DSA
  • Note
  • 7 Topics
  • 37 Offline Downloads
  • Uploaded 8 months ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

Downloaded from www.bhawesh.com.np Data Structure:It is a wave to organize the data in some way so we can do the operations on these data in effective way. Data structure may be organized in many different ways. The logical or mathematical model of a particular organization of data is called data structure. Choice of data model depends on two considerations. It must be rich enough in structure to mirror the actual relationship of the data in the real world. The structure should be simple enough that one can effectively process the data when necessary. Data structure can be classified as:1. Linear data structure:Processing of data items by linear fashion is linear data structure e.g. array, stack, queue, linked list. i/p o/p In case of stack:- -Last input is the first output 1 input process is called push. 2 Output process is called pop. In case of queue - First input is the first output. 3 Input is called rear. 4 Output is called front. In case of linked list start info info mation Downloaded from www.bhawesh.com.np info mation

Text from page-2

Downloaded from www.bhawesh.com.np First part consists of information and second part consists of pointer to second block. 2. Non Linear data structure:A data structure in which insertion and deletion is not possible in a linear fashion is called non –linear data structure . E.g. tree, graph. student Student_Id Name address Branch BE F_name L-name street BCA BIT area Computer Electro nices - It is hierarchical in nature. Graph:Nepalgunj Illam Kathmandu Birgunj Biratnagar fig. airlines flights - Contents relationship between pair of elements which is not in hierarchical in nature. 3. Abstract Data type (ADT):ADT is used to specify the logical properties of the data type. It is a set of operation which is called with the component of the element of that abstract data type. e. g. list as ADT Component the term ‘ADT’ refers to basic mathematical concept that defines the data type. Item Operations -Insertion Downloaded from www.bhawesh.com.np

Text from page-3

Downloaded from www.bhawesh.com.np - Deletion - Search - Display Here, item is component of ADT. An ADT consists of two parts. (a) value definition i. Definition clause ii. Condition clause (b) operator definition # ADT for Relation:/*value of definition */ Abstract type def <integer, integer> RTIONAL // value definition Condition RATIONAL [1] = 0; // denominator is not equal to zero; n cond . /* operator definition * / Abstract RATIONAL make rational (a, b) Int a,b; Precondition b! = 0; Post condition make rational [0] == a; Make rational [1] == b; Abstract RATIONAL add (a, b) RATIONAL a,b; Past condition add [1] == a[1] * b[1]; Add [0] == a[a] * b[1] + b[0] * a[1]; Abstract RATIONAL mult (a,b) RATIOANL a, b; Post condition mult [0] ==a[a] * b[0]; Mult [1] == a[1] *b[1]; Abstract RATIONAL equal (a,b) RATIONAL a,b; Post condition equal == (a[0] * b[1] == b [0] * a[1]); Downloaded from www.bhawesh.com.np

Text from page-4

Downloaded from www.bhawesh.com.np Goals of data structure:Data structure involves two complementary goals:(1) identify and develop useful mathematical entities and operations and determine what class of problems can be solved by using these entities and operations. (2) Determine representation fro those abstract entities and implement the abstract operations on these concrete representations. Properties of Data structure:- Generalization:Entity generalizes the primitive data type (integer, real, float) - Encapsulation:All the operation of that type can be localized to one section of program. Downloaded from www.bhawesh.com.np

Lecture Notes