algorithms code

16 flashcardsby Sabs2023
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
algorithm for pushing an item in a stack in psuedocode
FUNCTION is_full(top)
IF top == MAX_SIZE - 1 THEN
RETURN True
ELSE
RETURN False
ENDIF
ENDFUNCTION


FUNCTION push(stack, top, data)
IF is_full(top) == True THEN
PRINT("Stack is full")
ELSE
top = top + 1
stack[top] = data
ENDIF
RETURN top
ENDFUNCTION
2
algorithm for popping an item off a stack
FUNCTION is_empty(top)
IF top == -1 THEN
RETURN True
ELSE
RETURN False
ENDIF
ENDFUNCTION

FUNCTION pop(stack, top)
IF is_empty(top) == True THEN
PRINT ("Stack is empty - nothing to pop")
popped_item = Null
ELSE
popped_item = stack[top]
top = top - 1
ENDIF
RETURN (popped_item, top)
ENDFUNCTION
3
how to enque item in queue
4
how to deque an item in queueu
5
how to traverse a linked list algoirthm
6
how to insert an item in a linked list algorithm(this code for how we implemented list)
7
how to delete nofde (.next = pointer)
8
linear search implentn
9
pre order traversal
10
inorder
11
postorder
12
binary search algorithm
13
bread
14
bubble sort
15
16
merge sort........AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Study all 16 cards for free