Professional Documents
Culture Documents
Algorithm
Rajasekaran S AP/IT
Problem Solving and Python Programming GE8151
Flow Chart
start
my_cards = [4,5,7,8,9]
length_of_my_cards = 5
temp_cards = [0,0,0,0,0,0]
my_cards
cur_card = my_cards[i]
False
cur_card < in_card
?
True False
flag = 0
temp_cards[j] = my_cards[i] ?
True
D A B C
Rajasekaran S AP/IT
Problem Solving and Python Programming GE8151
D A B C
temp_cards[j] = in_card
flag = 1
J=j+1
temp_cards[j] = my_cards[i]
i = i + 1, j = j + 1
True
i < length_of_my_cards
False
my_cards = temp_cards
my_cards
stop
Rajasekaran S AP/IT
Problem Solving and Python Programming GE8151
Pseudo code
START
SET my_cards = [4,5,7,8,9]
SET length_of_my_cards = 5
SET in_card = 6
SET flag = 0
SET i = 0
SET j = 0
SET temp_cards = [0,0,0,0,0,0]
PRINT “Before Insertion : “ my_cards
WHILE i less than or equal to length_of_my_cards
SET cur_card = my_cards[i]
IF cur_card < in_card THEN
temp_cards[j] = my_cards[i]
ELSE
IF flag = 0 THEN
temp_cards[j] = in_card
flag = 1
INCREMENT j
CONTINUE
ELSE
temp_cards[j] = my_cards[i]
END IF
END IF
INCREMENT i
INCREMENT j
END WHILE
SET my_cards = temp_cards
PRINT “After Insertion : “ my_cards
STOP
Rajasekaran S AP/IT