CT: Weekly Assignments (Consolidated)
๐ Week 1: Algorithms & Flowcharts (Basic Procedures)
Question 1
The value of A is _ _? Accepted Answer: 7
Question 2
The value of B is _ _? Accepted Answer: 15
Question 3
The value of C is _ _? Accepted Answer: 8
Question 4
Shopping Bills dataset procedure: Average of total bill amount from โSV Storesโ. Accepted Answer: Average of total bill amount from โSV Storesโ
Question 5
Words dataset pseudocode: Counts of Verb (A) and Adverb (B). Accepted Answer: 35 & 13
Question 6
Scores dataset procedure: Comparing birth dates (First vs Second half). Accepted Answer: When there are more students born in the second half than the first half of the year.
Question 7
Shopping Bills dataset: Distinct stores visited by Neeraja. Accepted Answer: Number of distinct stores which Neeraja has visited
Question 8
Finding mistakes in procedure (Step 6 loop indication). Accepted Answer: Step 6: Incorrect step indicated from where the procedure has to be repeated
Question 9
Data Sanity check (Card number type, Letter Count value). Accepted Answers:
- Row 1: Incorrect data type of card number
- Row 4: Invalid value of Letter Count
Question 10
Words procedure: Adjectives at end of sentence. Accepted Answer: Number of adjectives which are at the end of a sentence
๐ Week 2: Variables & Iteration
Question 1
Scores dataset: Counting students from Bengaluru with Total > Avg. Mistake identification. Accepted Answers:
- Step 5
- Step 6
Question 2
Chemistry vs Math marks comparison (Min/Max logic). Accepted Answer: A = Lowest marks in Chemistry, B = Highest marks in Mathematics
Question 3
Counting male students with Physics < Math and Chem > Physics. Accepted Answers:
- Step 2
- Step 5
Question 4
Words dataset: Finding shortest sentence based on letters. Accepted Answer: Length of the shortest sentence based on the number of letters
Question 5
Finding smallest among a, b, c. Accepted Answer: Smallest among a, b , and c
Question 6
Town/City aggregation (Vellore most frequent?). Accepted Answer: Chennai (Wait, Accepted answer says Chennai, logic check needed in Theory phase).
Question 7
Flowchart execution: Rida vs Siddharth scores. Accepted Answer: A = 173 , B = โRidaโ
Question 8
Scores pseudocode: Students with >80 in exactly two subjects. Accepted Answer: Number of students who scored more than 80 marks in exactly two subjects
Question 9
Shopping Bills: Bananas and Total >= 600. Accepted Answer: Number of bills that contain the item โBananasโ and total is more than or equal to 600
Question 10
Scores pseudocode completion: Female Chennai vs Male Bangalore. Accepted Answer: Statement 1: A = A + 1, Statement 2: A > B
๐ Week 3: Conditional Logic & Nested Iteration
Question 1
Words dataset: Words with even letter count. Accepted Answer: Number of words with an even letter count
Question 2
Adverbs with odd letter count. Accepted Answer: Number of adverbs with an odd letter count
Question 3
Scores dataset: Female students scores >= 60 in all three. Accepted Answer: All female students have scores greater than or equal to 60 in Physics, Chemistry and Maths
Question 4
Shopping Bills: Min bill > Avg bill check. Accepted Answer: (Image option for correct code fragment)
Question 5
Scores dataset: Students below 60 in at least one subject. Accepted Answer: Number of students scored below 60 in at least any one subject
Question 6
Scores dataset: Total > AvgT but Sub < AvgSub in 2 subjects. Accepted Answer: (Image option A)
Question 7
Scores dataset: Madurai students vs Vellore/Chennai averages. Accepted Answer: greater than the average marks of students from Vellore but less than that of Chennai
Question 8
Mistake finding: Female students below average. Accepted Answers:
- Line 3: Incorrect initialization of B
- Line 7: Incorrect Update of B
- Line 13: Incorrect Update of B
Question 9
Scores dataset: Lowest marks only in Physics. Accepted Answer: Number of students with lowest marks only in Physics out of their three subjectsโ marks
Question 10
Words dataset: Words ending with comma & letter count > avg. Accepted Answer: Number of words that end with a comma and have a letter count greater than the average letter count of dataset.
๐ Week 4: Complex Procedures & Pattern Matching
Question 1
Words dataset: Words with at least one letter followed by vowel. Accepted Answer: Number of words with at least one letter followed by a vowel
Question 2
Olympics: Pairs from same country with different medals. Accepted Answer: Number of pairs of players from the same country with different medals
Question 3
Library: Max books by an author. Accepted Answer: Maximum number of books published by an author
Question 4
Library: Number of authors. Accepted Answer: Number of authors
Question 5
Shopping Bills: Ratio of Soap+Facewash to Facewash. Accepted Answer: (Image containing correct code)
Question 6
Words: Pairs with at least two consecutive consonants. Accepted Answer: Number of pairs of words with at least two consecutive consonants
Question 7
Conjugate words (Vowel/Consonant counts). Accepted Answer: Line 17: Incorrect initialization of i
Question 8
Scores: Club joining conditions. Accepted Answer: The student cannot join any club
Question 9
Scores: Multiple club joining condition. Accepted Answer: A student cannot join more than one club
Question 10
Words: Words before first adverb. Accepted Answer: Number of words before the first adverb or full stop in every sentence
๐ Week 5: Lists & Nested Iteration
Question 1
List Logic: last(element).
Accepted Answer: [210, 198, 188, 173, 240]
Question 2
List Logic: last(init(element)).
Accepted Answer: [210, 198, 188, 173, 240]
Question 3
Common elements count logic (List Intersection). Accepted Answer: 0
Question 4
List difference logic (L1 - L2). Accepted Answer: It will contain all the elements of L1 that are not present in L2
Question 5
List length logic. Accepted Answer: length(L1) >= length(L)
Question 6
isPerfect procedure validity (all unique letters).
Accepted Answer: (Correct code block with if(member(C,A)) return False)
Question 7
Positive sentiment sentence count. Accepted Answer: 2
Question 8
โNouns after Adjectivesโ verification logic mistakes. Accepted Answers:
- Line 7: Invalid increment of trueCount
- Line 9 - 11: These three lines should be replaced by
totalCount = totalCount + 1
Question 9
doSomething(X) logic (Prime number check).
Accepted Answer: X is a prime number
Question 10
Filtering list with Prime check. Accepted Answer: M = [11, 7]
๐ Week 6: Advanced Lists & Filtering
Question 1
Scores: <75 in Math/Phy but >75 in Chem. Accepted Answer: Number of students who have scored less than 75 in both Mathematics and Physics, but more than 75 in Chemistry
Question 2
Words: Nouns immediately after Adjectives. Accepted Answer: The list of nouns that come immediately after an adjective
Question 3
Sorting/Unique list logic mistakes. Accepted Answers:
- Error in line 2
- Error in line 5
Question 4
visitedShop: Unique customers per shop.
Accepted Answers:
- Error in line 2
- Error in line 7
- Error in line 16
Question 5
Closest station pair (first instance).
Accepted Answer: if(diff < min){ min = diff pair = [first(prev), first(x)] }
Question 6
Closest station pair (last instance).
Accepted Answer: if(diff <= min){ min = diff pair = [first(prev), first(x)] }
Question 7
Train waiting time average. Accepted Answer: No error
Question 8
flag1 logic (Starting/Ending station check).
Accepted Answer: It is True if and only if stn is a starting or ending station for at least one train in the list
Question 9
count logic (Intermediate station check).
Accepted Answer: It is the number of trains for which stn is neither a starting nor an ending station
Question 10
Relation between flag1 and flag2 (start/end logic).
Accepted Answer: flag1 and flag2 always store the same value
๐ Week 7: Dictionary Basics
Question 1
Dictionary properties (Keys unique). Accepted Answer: For keys a and b in D, a != b is always True.
Question 2
Dictionary Update: โreluctantโ letter counts. Accepted Answer: 4
Question 3
Author book count dictionary mistakes. Accepted Answers:
- Replacing the condition given in line 4 with
if(not isKey(A, X.Author)) - Interchanging Line 5 and 8 will provide the correct result.
Question 4
First book genre dictionary mistakes. Accepted Answer: Line 4: Incorrect conditional statment
Question 5
List unique filtering order.
Accepted Answer: [3, 4, 5, 1, 9, 6]
Question 6
List of lists of unique words. Accepted Answer: List of lists of unique words of each sentence from the โWordsโ dataset
Question 7
List of unique alphabets from Words dataset. Accepted Answer: List of unique alphabets from the โWordsโ dataset.
Question 8
seqDict[n] == 0 (No subject > avg).
Accepted Answer: The student has scored more than the average marks in Mathematics only (Wait, logic check: 0 usually means NO. Option says Math ONLY? Accepted answer says Math Only. Will verify in Theory).
Question 9
seqDict[n] == 1 definition.
Accepted Answers:
- The student has scored more than the average marks in Mathematics and might have scored more than the average marks in Physics but not in Chemistry.
- The student has scored more than the average marks in Mathematics and might have scored more than the average marks in Chemistry but not in Physics.
Question 10
Word sentence frequency dictionary. Accepted Answer: Dictionary with words as keys mapped to the number of sentences in which the word is present.
๐ Week 8: Advanced Dictionaries & File Handling
Question 1
Scores: Cities with Lowest Math Marks. Accepted Answer: A = Number of cities where students score the lowest marks in Mathematics, B = The lowest marks in Mathematics
Question 2
Most frequent Physics marks. Accepted Answer: Most frequent marks in Physics
Question 3
Students with >1 eligible subject (Highest in town). Accepted Answer: 10
Question 4
Nested Dictionary D[Customer][Shop][Category] mistakes.
Accepted Answers:
- Error in Line 10
- Error in Line 14
Question 5
Day frequency dictionary initialization. Accepted Answer: (Code with explicit initialization of M, Tuโฆ to 0)
Question 6
Trains per day frequency analysis. Accepted Answer: (Inferred: Most frequent day logic or distribution count)
๐ Week 9: Graphs & Networks (Part 1)
Question 1
Graph Edge Definition (Same City AND Gender). Accepted Answer: they are from the same city/town and have the same gender
Question 2
Clique Properties (Gender/City). Accepted Answers:
- All students in a given clique have the same gender
- All students in a given clique are from the same city/town
Question 3
Collaboration Matrix generation. Accepted Answer: It represents the number of books in which authors i and j have collaborated
Question 4
Matrix Max Value (aVar).
Accepted Answer: 5
Question 5
Location of Max Value (bVar).
Accepted Answer: 3
Question 6
Count of non-zero entries (Max count). Accepted Answer: 1
Question 7
Row index of max count. Accepted Answer: 4
Question 8
Sum of row entries (Max sum). Accepted Answer: 8
Question 9
Row index of max sum. Accepted Answer: 2
Question 10
Count of rows with exactly one non-zero entry. Accepted Answer: 7
Question 11
List of such rows. Accepted Answer: 6
Question 12
isClique procedure logic.
Accepted Answers:
if (i != j and colab[i][j] == 0){ return(False) }if(i != j){ if(colab[i][j] == 0){ return(False) } }
Question 13
Graph Representation (Matrix for n=5). Accepted Answer: (Image Option C)
Question 14
isAncestor procedure logic (Trace path).
Accepted Answer: if(A[k][c] == 1){ if(c == j){ return(True) } k = c flag = True exitloop }
๐ Week 10: Graphs & Matrix Algorithms
Question 1
Physics Matrix logic (Score difference). Accepted Answer: i scored at least 10 and at most 20 more marks in Physics than j
Question 2
Asymmetric relation property. Accepted Answer: For all i, j with i j, if matrixPh[i][j] = 1 then matrixPh[j][i] = 0
Question 3
matrixHelp properties (Sum of Ch, Ph, Ma matrices).
Accepted Answers:
- 0 โ matrixHelp[i][j] โ 3
- matrixHelp[i][j] + matrixHelp[j][i] โ 3
- if matrixHelp[i][j] = 3, then matrixHelp[j][i] = 0
Question 4
Helpers count (At least one subject vs All subjects).
Accepted Answer: if(i < j){ if(matrixHelp[i][j] > 0 and matrixHelp[j][i] > 0){ A = A + 1 } } if(matrixHelp[i][j] > 2){ B = B + 1 }
Question 5
Co-author matrix generation (Self-loop exclusion).
Accepted Answer: if(j != k){ matrix[j][k] = matrix[j][k] + 1 }
Question 6
Matrix2 definition (Triadic closure/Common neighbor). Accepted Answer: List of authors who have co-authored a book with both i and j
Question 7
Relationship between Matrix (Direct) and Matrix2 (Indirect). Accepted Answers:
- matrix[i] [j] = 0 and matrix2[i] [j] = [ ]
- matrix[i][j] > 0 and matrix2[i][j] = [ ]
- matrix[i][j] > 0 and matrix2[i][j] [ ]
Question 8
findAuthor (Max Co-authors).
Accepted Answers:
- (Standard Row Sum Logic)
- (Standard Column Sum Logic due to symmetry)
Question 9
findGoodSet logic (Triangles validation).
Accepted Answer: If there exist three customers such that every pair of customers among them have visited only one and the same shop in common.
Question 10
findTopCustomer (Max shopping partners).
Accepted Answer: Logic counting length(M[i][j]) > 1 (At least two shops).
๐ Week 11: Recursion & Advanced Procedures
Question 1
Recursive reverse(L).
Accepted Answers:
return([last(L)] ++ reverse(init(L)))return([last(L)] ++ reverse(init(rest(L))) ++ [first(L)])(Wait, this looks like palindrome logic in options, but accepted answer is reversal).return([last(L)] ++ reverse(rest(init(L))) ++ [first(L)])
Question 2
Recursive accumulation value. Accepted Answer: Scores list with 23:50/95 and 23:53/65.
Question 3
Interpretation of submissions variable.
Accepted Answer: The list of the last submissions made by the students sorted in the ascending order of time.
Question 4
Getting first submissions sorted ascending.
Accepted Answer: reverse(getSubs(reverse(scores)))
Question 5
blankSlate (Wins == Losses) Recursive helper.
Accepted Answers:
if(last(L) == "won") return(+1) else return(-1)if(first(L) == "won") return(+1) else return(-1)
Question 6
Recursive matchThem (Pairing first and last).
Accepted Answers:
- Base case length==2, else
[first, last] ++ recursive(middle) - Base case length==0, else
[first, last] ++ recursive(middle)
Question 7
Iterative matchThem equivalence.
Accepted Answer: While loop pairing first/last and reducing list.
Question 8
DFS Traversal (Stack/Recursion trace).
Accepted Answer: [0, 1, 2, 3, 5, 4]
Question 9
DFS Nodes visited order from 5. Accepted Answer: Cannot be determined (Depends on neighbor order in Adjacency Matrix/List).
Question 10
Graph Connectivity check via DFS. Accepted Answers:
- nodes is equal to
[0, 1, 2, 3, 4, 5] - The value of nodes is independent of start
- The graph is connected.
Question 11
DFS Tree reconstruction matrix. Accepted Answer: (Image Option B)