Lecture 6: Stack
STACK
•Stack is a linear data structure.
•Follows the principle of LIFO (Last in First out)
•Any data structure use the LIFO principle, it can
be called as STACK.
STACK
•Stack is a linear data structure.
•Follows the principle of LIFO (Last in First out)
•Any data structure use the LIFO principle, it can
be called as STACK.
linked list is a data structure used for storing collections of data.
A linked list has the following properties:
1. Successive elements are connected by pointers.
2. The last element points to NULL.
3. Can grow or shrink in size during execution of a program.
4. Can be made just as long as required (until systems memory exhausts).
5. Does not waste memory space. It allocates memory as list grows.
-Arrays are widely used in any programming language. It is extremely useful in cases where we need to store the similar set of elements.It helps in reducing the program complexity and increases the programmer’s productivity.
Arrays can be categorized into the following:
1-Single Dimensional array.
2-Double Dimensional array.
3-Multidimensional array.
-Pointer is a variable that is capable to hold the address of another variable.
An algorithm is the step by step clear instructions to solve a given problem.
Complexity of an Algorithm
1.Space Complexity of a program is the amount of memory it needs to run to completion.
2. Time complexity of a program is the amount of computer time it needs to run to completion. The time complexity is of two types such as:
a) Compilation time
b) Runtime
Data structure is a particular way of storing and organizing data in a
computer so that it can be used efficiently.
General data structure types include arrays, files, linked lists, stacks, queues,
trees, graphs and so on.
Data structures are classified into two types:
1- Linear data structures: elements can be accessed in a sequential order
(e.g. Arrays, Linked Lists, Stacks and Queues).
2- Non – linear data structures: elements can be accessed in a random order
(e.g. Trees, tables, sets, graphs).