Q4e) (10pts) Assume that you are given an array that contains only Os and 1s. De
ID: 3599903 • Letter: Q
Question
Q4e) (10pts) Assume that you are given an array that contains only Os and 1s. Describe an efficient algorithm that computes 25th and 75th percentile of the array and write down your algorithm's complexity. Q5) (15 pts) You interview a number of applicants for a job and the cost of firing an employee and hiring a new one increases as you do more interviews, in particular, firing the current employee and hiring the ith applicant has the cost of 5000i2 TL. Given that you use the Randomized-Hire- Assistant Algorithm given below, what is the expected cost of hiring and firings? RANDOMIZED-HIRE-ASSISTANT(n) 1 randomly permute the list of candidate 2 best-0 3 for i-1 to n 4 do interview candidate i 5 if candidate i is better than candidate best 6 7 then best-i hire candidate iExplanation / Answer
#include "des56.h"
#include
#include
#include
//Use these constants to specify ENCRYPT or DECRYPT in the fencrypt function call. (The middle parameter)
#define ENCRYPT 0
#define DECRYPT 1
/*This function takes the XOR of block A and block B and stores the result in block "result"*/
/*Note that it is possible that "result" is the same as "A" (or "B").*/
/*For example:
XORblock(block1,IV,block1);
Would XOR the first block with the IV and put the result in block1*/
void XORblock(char A[8],char B[8],char result[8])
{
int i = 0;
for(;i<8;i++)
result[i] = A[i]^B[i];
}
/*This function takes a block as input and prints the corresponding hex to the terminal*/
void printhex(unsigned char block[8])
{
int i=0;
for(;i<8;i++)
printf(" 0x%x ",block[i]);
puts("");
}
void cbc_enc_three_blocks(char block1[8],char block2[8], char block3[8], char IV[8],keysched *ks)
{
// You write this code
}
void cbc_dec_three_blocks(char block1[8],char block2[8], char block3[8], char IV[8],keysched *ks)
{
// You write this code
}
int main()
{
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.