Docsity

Data Structures and Algorithm Analysis: Fundamentals and Asymptotic Notations, Study notes of Data Structures and Algorithms

Partial preview of the text

Download Data Structures and Algorithm Analysis: Fundamentals and Asymptotic Notations and more Study notes Data Structures and Algorithms in PDF only on Docsity!

Data Structures & Algorithms

Course Information

  • (^) Textbooks
    • (^) Data Structures and Algorithms

by A. V. Aho, J. E. Hopcroft, J. D. Ullman

  • (^) Data Structures Using C and C++

by Y. Langsam, M. J. Augenstein, A. M. Tenenbaum

  • (^) Algorithms in C++

by Robert Sedgewick

Introduction to Data Structure and

Abstract Data Types

What is Data Structure?

  • (^) Data structure is a representation of data

and the operations allowed on that data.

  • (^) A data structure is a way to store and

organize data in order to facilitate the

access and modifications.

  • (^) Data Structure are the method of

representing of logical relationships

between individual data elements related

to the solution of a given problem.

Basic Data Structure

Non Primitive Linear Data Structures (^) Non-Linear Data Structures Arrays Linked Lists Stacks Queues Trees Graphs Hash Tables

array Linked list tree queue stack Graph

Types of Data Structure

  • (^) Linear: In a linear data structure , data elements are arranged in a linear order where each and every elements are attached to its previous and next adjacent. In linear data structure, single level is involved. Therefore, we can traverse all the elements in single run only. Linear data structures are easy to implement because computer memory is arranged in a linear way. - (^) Array: Fixed-size - (^) Linked-list: Variable-size - (^) Stack: Add to top and remove from top - (^) Queue: Add to back and remove from front - (^) Priority queue: Add anywhere, remove the highest
priority

Types of Data Structure

  • Non-Linear: Data structures where data elements are not arranged sequentially or linearly are called non-linear data structures. In a non-linear data structure, single level is not involved. Therefore, we can’t traverse all the elements in single run only. Non-linear data structures are not easy to implement in comparison to linear data structure. It utilizes computer memory efficiently in comparison to a linear data structure. - (^) Hash tables: Unordered lists which use a ‘hash function’ to insert and search - (^) Tree: Data is organized in branches. - (^) Graph: A more general branching structure, with less strict connection conditions than for a tree

Abstract Data Type and Data Structure

  • (^) Definition:-
    • Abstract Data Types (ADTs) stores data and allow various operations on the data to access and change it.
    • (^) A mathematical model, together with various operations defined on the model
    • (^) An ADT is a collection of data and associated operations for manipulating that data
  • (^) Data Structures
    • (^) Physical implementation of an ADT
    • (^) data structures used in implementations are provided in a language (primitive or built-in) or are built from the language constructs (user-defined)
    • (^) Each operation associated with the ADT is implemented by one or more subroutines in the implementation

Abstract Data Type

  • (^) ADTs support abstraction, encapsulation, and information hiding.
  • Abstraction is the structuring of a problem into well-defined entities by defining their data and operations.
  • (^) The principle of hiding the used data structure and to only provide a well-defined interface is known as encapsulation.

Note..

  • (^) No single data structure works well for all purposes, and

so it is important to know the strengths and limitations

of several of them

Array Data structures

n++; for(i=n;i>pos;i--) a[i]=a[i-1]; A[pos]=ele;

Arrays Deletion item=a[pos]; for(i=pos;i

Stacks

Collection with access only to the last element

inserted

Last in first out

insert/push

• remove/pop

• top

• make empty

Data4 Top Data Data Data