Advance Level Coding Questions

Duration: 47 min

This video lesson is available to enrolled students.

Return to /learn/COGNIZANT-PREPARATION/technical-assessment/c-programming-by-yash-sir/c-programming/asset-advance-level-coding-questions after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Communication Round: Vocabulary, Subject Verb Agreement (Verb Noun Agreement), Tenses, Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Cloze Test (Cloze Passage), Sentence Correction (Error Correction), Sentence Completion (Fill in the blanks), Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Direct and Indirect Speech, Active Passive Voice (Voice), Verbal Analogy (Word Based Analogy), Articles, Preposition, Conjunction, Sentence Construction, English Writing Ability, Communication Assessment
  2. Quantitative Aptitude: Ratio and Proportion (Ratios), Divisibility Rules, Data Interpretation, Mixture and Alligation, Permutation and Combination, Logarithm, Number System, HCF LCM, Speed Time and Distance, Percentage, Average, Powers and Exponents (Surds and Indices), Time and Work, Mensuration and Geometry, Age Problems, Pipe and Cistern, Probability, Profit and Loss, Simple Interest and Compound Interest, Algebra
  3. Analytical and Logical Reasoning: Series (Number and Letter Series) (Numerical Relations and Reasoning), Coding Decoding, Data Sufficiency, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Directions (Direction Test), Ranking, Order and Sequence, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Selection Decision Table (Decision Making), Logical Sequence Of Words, Puzzle Solving (Puzzles), Syllogisms, Seating Arrangements, Calendar, Clock, Blood Relations, Cubes & Dices, Venn Diagram, Analytical Reasoning (Counting Figures Reasoning)
  4. Cognizant Gaming Aptitude: Gamified / Game Based Aptitude
  5. Java (Cluster 1): Java
  6. ANSI SQL MySQL (Cluster 1,2,3): SQL
  7. HTML, CSS, JavaScript (Cluster 1,3): HTML, CSS, JavaScript
  8. Python (Cluster 2): Python for Placements by Yash Sir
  9. Cloud Fundamentals (Cluster 2): Emerging Tech Trends
  10. C# (Cluster 3): C#
  11. OOPs: Object Oriented Programming (OOPS)
  12. Technical Assessment (Coding): Coding Questions by Yash Sir, C Programming by Yash Sir, Programming in C++, Pseudo Codes
  13. Data Structures: Introduction to DS, Array, Stack, Queue, Linked List, Tree, Graphs, Hashing
  14. DBMS: Basics of DBMS, ER Diagram, Relational Model & Functional Dependencies, Keys & Integrity Constraints, Normalization (1NF - BCNF), Decomposition Properties & 4NF, File Organization & Indexing, Relational Algebra, Relational Calculus, Transaction Management, Concurrency Control, Database Recovery, ORDBMS, Database Security & Authorization, Query Processing & Optimization, Enhanced Data Models, Data Warehousing & Mining, Big Data Systems, NoSQL
  15. Operating Systems: Introduction to OS, Process Management, CPU Scheduling, Process Synchronization, Deadlock, Threads & Process Creation, Memory Management, Virtual Memory, Disc Scheduling, File Management, Windows OS, Linux OS, Security, Distributed Systems, Virtual Machines
  16. Computer Networks: Introduction to CN, Data Communication, DLL: Access Control, DLL: Flow Control, DLL: Error Control, DLL: Framing, Data Link Layer - Ethernet, Net Layer: IPv4 & Proto, Net Layer: IP Addressing, Net Layer:Routing Protocol, Transport Layer Services, TL: Congestion & UDP, Application Layer, Hardware basics, Network Security, Mobile Technology, Cloud Computing and IoT, Cyber and Info Security
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This educational video is a C programming lecture delivered by an instructor identified as Yash Jain Sir. The session begins with a brief introduction showing code typing, followed by a schedule for an aptitude batch. The core of the lecture addresses two distinct algorithmic problems. The first problem involves a scenario where a character named Jetha visits chocolate shops numbered 1 to N, starting from a specific shop 'i', with the total number of shops determined by a bit length 'L'. The instructor derives the formula N = 2^L and calculates the maximum shops visitable. The second problem focuses on bit manipulation, specifically counting the number of set bits (1s) in a positive integer N. The instructor demonstrates the logic using binary representations of numbers like 6 and 8, explains the use of bitwise operators like AND and right shift, and provides C code implementations for both problems. The lecture concludes with an analysis of the time complexity for the bit counting algorithm, establishing it as O(log n).

Chapters

  1. 0:00 – 2:00 00:00-02:00

    The video opens with a title card reading 'C PROGRAMMING' and 'CODING QUESTIONS'. A person is seen typing on a laptop keyboard. The screen displays a C code snippet involving a loop structure. Visible lines of code include `for(int j=1; j<=1000000; j+=i)`, `ne_prost[j]=true;`, `int n;`, `cin>>n;`, and `while(1)`. The code also shows an `if` condition checking `n%==0` and a `scanf` statement. This initial segment sets the context for a programming tutorial, likely demonstrating a solution to a competitive programming problem.

  2. 2:00 – 5:00 02:00-05:00

    The scene transitions to a classroom setting where an instructor, identified by the logo 'KG' and text 'YASH JAIN SIR', stands before a digital screen. The screen displays a schedule titled 'APTITUDE BATCH'. The schedule lists dates from '01 June 2022' to '15 June 2022', with the educator listed as 'Yash Jain Sir' and the time as '08:30 PM'. The instructor points to specific dates, such as '05 June 2022' and '12 June 2022', which are highlighted in green. Handwritten notes on the screen include '4500' and '28400', possibly referring to batch numbers or student counts. The bottom banner promotes 'Mera Placement Hoga PRIME' with contact numbers.

  3. 5:00 – 10:00 05:00-10:00

    The instructor begins explaining a specific problem statement displayed on the screen. The text reads: 'Jetha like chocolates and he loves to try different ones. There are N shops in a market labelled from 1 to N... Jetha starts from ith shop and goes ahead to each and every shop... You have been given L denoting number of bits required to represent N. You need to return the maximum number of shops he can visit.' To the right, there is a meme image titled '*When Someone Unknown Reacts Haha On my Profile Pic'. The instructor writes '3-5 min' and 'Online gdb' on the screen, indicating the time limit and debugging tool for the problem.

  4. 10:00 – 15:00 10:00-15:00

    The instructor elaborates on the logic of the shop visiting problem. He writes a sequence of numbers '1 2 3 4 ... N' on the screen to represent the shops. He circles the number '3' and writes 'i=3' above it, indicating the starting shop. He draws an arrow pointing from the starting shop towards the end of the sequence. He also writes '3-5 min' again, emphasizing the time constraint. The visual aids help in understanding the movement from the starting index 'i' to the end of the range 'N'.

  5. 15:00 – 20:00 15:00-20:00

    The instructor derives the mathematical formula for the total number of shops. He writes 'N = 2^L' on the board, explaining that N is determined by the number of bits L. He uses the example from the problem where L=3, calculating '2^3 = 8'. He then performs a subtraction '8-2 = 6' to arrive at the output for Example 1. He connects the calculated value of N to the sequence of shops, showing how the maximum number of shops is derived from the bit length provided in the input.

  6. 20:00 – 25:00 20:00-25:00

    The screen displays a C code implementation for the first problem. The code includes `int i, l, j;` and `scanf("%d %d", &i, &l);`. The core logic is `j=pow(2,l)-i;` followed by `printf("%d\n",j);`. The instructor points to the code, explaining how the `pow` function is used to calculate 2 raised to the power of L. He writes '30 mins' and '30x' on the board, possibly referring to the duration or a multiplier in a different context. The code snippet demonstrates a direct mathematical approach to solving the problem.

  7. 25:00 – 30:00 25:00-30:00

    The topic shifts to a new problem: 'Given a positive integer N, print count of set bits in it.' The instructor provides two examples. Example 1 shows Input N=6 with Output 2, explaining that the binary representation is '110', so the count of set bits is 2. Example 2 shows Input 8 with Output 1, explaining that the binary representation is '1000', so the count is 1. He writes '0/1' and 'set bit' on the board to clarify the binary nature of the problem. He also writes '3-5 min' to indicate the time limit for this problem.

  8. 30:00 – 35:00 30:00-35:00

    The instructor demonstrates the manual process of counting set bits. He writes '0 & 1' and '1 & 1' to show how bitwise AND operations work. He draws a loop structure to explain the iteration process. He writes 'P+2+2 = 0+1+1 = 2' to show the summation of set bits. He also writes '0001' and '0000' to illustrate the binary values being processed. This section focuses on the algorithmic logic before showing the code.

  9. 35:00 – 40:00 35:00-40:00

    The screen shows the C code for counting set bits. The function `unsigned int countSetBits(unsigned int n)` is defined. Inside, `unsigned int count = 0;` initializes the counter. The loop `while(n)` checks if n is non-zero. Inside the loop, `count = count + (n & 1);` adds the least significant bit to the count. Then `n = n/2;` is shown with a comment `// n = n >> 1;`. The instructor explains bitwise shift operators, writing `a >> b` for right shift and `a << b` for left shift, and their mathematical equivalents `a / 2^b` and `a * 2^b`.

  10. 40:00 – 45:00 40:00-45:00

    The instructor discusses the Time Complexity of the bit counting algorithm. He writes 'O(log n)' on the board. He explains that the number of iterations depends on the number of bits in N. He writes ranges like '0-3 -> 2 bit' and '4-7 -> 3 bit' to illustrate how the number of bits increases with the value of N. He calculates '2^2 = 4' and '2^3 = 8' to show the relationship between powers of 2 and bit lengths. He also writes 'ceil(log2 N) = O(log N)' to formalize the complexity analysis.

  11. 45:00 – 46:39 45:00-46:39

    The video concludes with a black screen displaying the text 'THANKS FOR WATCHING' in large white letters. This signals the end of the lecture session. The instructor has covered the problem statements, logical derivations, code implementations, and complexity analysis for both the shop visiting problem and the set bit counting problem.

The lecture provides a comprehensive guide to solving two specific C programming problems. The first problem requires calculating the maximum number of shops a person can visit given a starting index and a bit length constraint. The instructor derives the formula N = 2^L and implements it using the `pow` function. The second problem involves counting the set bits in an integer, a fundamental bit manipulation task. The instructor explains the binary representation of numbers, demonstrates the logic using bitwise AND and right shift operators, and provides a complete C function. Finally, the time complexity is analyzed as O(log n), linking the number of iterations to the number of bits in the input number. The session effectively bridges theoretical concepts like binary representation with practical coding skills.

Loading lesson…