Posts

Showing posts from February, 2021

LINEAR DATA STRUCTURE : STACK

Image
 What is a stack? A stack is a linear data structure in which the addition and deletion of data are done from the same end. This end is often referred to as the top of a stack. Last-In-First-Out (LIFO) structure. STACK ADT: DATA: It is a finite sequence of elements of a particular type. (arrays / linked list) OPERATIONS: 1. Initialize a stack. 2. check whether the stack is empty. 3. check whether the stack is full. 4. Insert at the top of stack if a stack is not full. This operation is called Push. 5. Delete a element from the top of stack if it is not empty. This operation is called Pop. 6. Retrieve an element from the top of stack. This operation is called Peek. STACK OPERATION Implementation of Stack: 1. Using Array 2. Using Linked List. Message Passing Methods in C: 1. Pass by Value / Call by Value. 2. Pass by Address / Call by Address. Implementation of a stack using arrays #include<stdio.h>   //pre-processor directive #include<unistd.h> #define MAX 5 str...

INTRODUCTION TO DATA STRUCTURE USING C

Image
  INTRODUCTION TO DATA STRUCTURE It is a way of storing and organizing the data into the memory so that it can be accessed efficiently.  In simple language, Data Structures are structures programmed to store ordered data, so that various operations can be performed on it easily. It represents the knowledge of data to be organized in memory. It should be designed and implemented in such a way that it reduces the complexity and increases efficiency. Abstract Data Type(ADT)  It is a mathematical /logical model that is used to specify the data and operations that can be performed on data. ADT = DATA + OPERATIONS (only for understanding purpose) Types of data structure  Linear Data Structure:   A  Linear data structure  has  data  elements arranged sequentially and each member element is connected to its previous and next element. Such  data structures  are easy to implement as computer memory is also sequential.  Examples of  ...