CHAPTER 1 Flashcards
INTRODUCTION/DEFINATION TO DATA STRUCTURE
- A DATA STRUCTURE IS THE LOGICAL ARRANGMENT OF DATA ELEMENT COMBINE WITH SET OF OPERATIONS THAT HELPS WITH ACCESS THE ELEMENTS
- SOME OF THE MORE COMMONLY USED DATA STRUCTURE ARE LINKLIST , ARRAY , TREE, QUEUE
TYPES OF DATA STRUCTURE
PRIMITIVE AND NON PRIMITIVE
EXAMPLE : PRIMITIVE
INT
FLOAT
DOUBLE
CHAR
TYPES OF NON PRIMITIVE WITH EXAMPLES
LINEAR AND NONLINEAR
LINEAR : ARRAY , STACL
NONLINEAR : GRAPH , TREE
ADVANTAGES & DISADVANTAGES OF POINTER
IT ALLOW YOU TO ACESS ANY MEMORY ADDRESS
- * Pointers can be used to return multiple values from a function.
- * Pointers allow C to support dynamic memory management.
- DISADVANTAGES OF POINTER
- IF POINTER REFREANCE INCORRECT VALUE IT EFFECT WHOLE PROGRAM
- POINTERS ARE SLOWER THAN NORMAL VARIABLESADVANTAGES & DISADVANTAGES OF POINTER
COMPLEXITY
complexity is ameasure of the interactions of the various elements of the software
2 TYPES OF COMPLEXITY
TIME COMP;EXITY , SPACE COMPLEXITY
TIME COMPLEXITY
- MOUNT OF COMPUTATIONAL TIME NEED TO EXECUTE THE PROGRAM AND GET THE INTENDED RESULT
- THERE ARE 3 COMPLEXITY ANALIZIES
- WORST CASE > BIG OH = O
- AVERAGE CASE > THETA =0( THETA)
- BEST CASE > OMEGA = (SIGN OF OHM )
- WORST CASE : BIG OH USES FOR WORST CASE & RESULT GETS IN UPPER BOUND
- AVERAGE CASE : THETA NOTATION USE FOR AVERAGE CASE AND RSULT GETS TIGHT BOUND
- BEST CASE : OMEGA NOTATION USE FOR BEST CASE , SO ON RESULT GETS WITH LOWER BOUND
- THERE ARE 3 COMPLEXITY ANALIZIES
SPACE COMPLEXITY
e space complexity of an algorithm or a computer program is theamount of memory space required to solve an instance of the computational problem
Algorithm
is a finite sequence of well-defined, computer-implementable instructions, typically to solve a class of problems
USES OF ALGORITHM (OR BENIFIT OF ANALYZE ALGORITHM )
- TO PREDICT REQUIRED RESOURSES
- TO PREDICT HOW FAST ALGORITHM WORK BASE ON PROBLEM SIZE
- TO KNOW COMPUTATIONAL TIME AND CPU CONSAMPTION
- TO KNOW MEMORY AND RAM CONSAMPTION
- TO PREDICT DESIGN AND CODE STRUCTRE
- TO MAKE CODE EASY TO UNDERSTAND
WHAT IS STACK?
A STACK IS A LINEAR DATA STRUCTURE WHICH STORES ITS ELEMENTS IN PARTICULAR ORDER. THIS ORDER FOLLOWED BY A STACK IS KNOWN AS LIFO (Last In Frist Out )
- A EXAMPLE OF REAL LIFE IS PLATES STACKED OVER ONE ANOTHER ON A TABLE
- THE PLATE WHICH IS AT THE TOP IS THE FIRST ONE TO BE REMOVED
PROPERTIES OF STACK
- FOLLOWS LIFO , LAST ELEMENT THAT IS INSERTED IS PUSHED OUT FIRST
- A POINTER KEEPS TRACK OF THE STACK’S TOPMOST (OR LAST) ELEMENT . THIS IS MANIPULATED ON THE BASIS OF OPERATIONS TO KEEP TRACK OF MOST RECENT ELEMENT
STACK MANIPULATION OPERATIONS
- PUSH OPERATION
- WHEN AN ELEMENT IS INSERTED INTO THE STACK , IT IS SAID THAT THE ELEMENT IS PUSHED INTO STACK , THE TIP POINTER IS MOVED UP TO POINT TO THE ELEMENT THAT IS INSERTED
- POP OPERATION
- WHEN AN ELEMNT IS REMOVED FROM THE STACK, IT IS SAID THAT THE ELEMENT IS POOPED FROM THE STACK , THE TOP POINTER IS MOVED DOWN TO POINT TO THE ELEMENT BELOW THE REMOVED ELEMENT
- PEEK OPERATION
- PEEK IS AN OPERATION THAT RETURNS THE VALUE OF THE TOPMOST ELEMENT OF THE STACK WITHOUT DELETING IT FROM STACK.