Lab 8 (19/04/2023
)
Problems for lab session:
Practicals
Part 1
- Write a function
shiftNmerge(data,N)
splitsdata
in two halves and performs a left-shift opration as follows:
data
= a binary value- Split
data
in 2-halves (X0 and Y0) and perform a left-shift opration on each part forN
number of bits to get (X1 and Y1)- Merge the previous output, i.e., X1 & Y1
- Write a function
PC_M2N(data, M, N)
that takes an M-bit input (data
) and compresses into to N-bit:
- The result MUST contain N bits, i.e., M-N bits are discarded
- The permutation and compression is based on the table below (taken from Geeks for Geeks)
Part 2
- Write a function to find GCD using Euclidean Algorithm