Chapter 2
Discrete Structure
TU BIT past exam questions
Past questions and answers
75 questions set from this chapter; 3 are most repeated (set, or a close variant set, in 3 or more exams). Most repeated first.
- Most repeated · 4 of 6 exams
- 2079 · 5 marks
Use mathematical induction to prove that the sum of the first odd positive integers is .
Similar questions: Prove that the sum of first (2080.1) · Using mathematical induction prove that sum (2082) · Use mathematical induction to show that (2078)
Answer
Claim: for all .
Basis (): LHS .
Inductive step: assume the statement holds for : . Then for :
So it holds for . By mathematical induction the sum of the first odd positive integers is .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- Most repeated · 3 of 6 exams
- 2080.1 · 6 marks
Prove that the sum of first odd integers is using mathematical induction.
Similar questions: Using mathematical induction prove that sum (2082) · Use mathematical induction to prove that (2079)
Answer
Claim: for all integers .
Basis (): the sum is .
Inductive hypothesis: assume that for some , .
Inductive step: for , the sum of the first odd integers is
Thus the statement holds for . By the principle of mathematical induction it holds for all .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- Most repeated · 3 of 6 exams
- 2082 · 5 marks
Using mathematical induction prove that sum of first odd integers is .
Similar questions: Prove that the sum of first (2080.1) · Use mathematical induction to prove that (2079)
Answer
Claim: for all .
Basis step: : LHS , RHS . True.
Inductive step: Assume : . Then
which is .
By the principle of mathematical induction, the sum of the first odd integers is for every .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2078 · 5 marks
Use mathematical induction to show that the sum of first positive integers is .
Similar questions: Use mathematical induction to prove that (2079)
Answer
Claim: : for all positive integers .
Basis step: for , LHS and RHS . So is true.
Inductive step: assume is true for some :
Add to both sides:
This is . Since the basis and inductive steps hold, by mathematical induction is true for all positive integers .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2079 · 5 marks
Write the Dijkstra's algorithm to find the shortest path between two nodes in graph.
Similar questions: Find the shortest path from $a$ (2082)
Answer
Dijkstra's algorithm finds the shortest path from a source vertex to all other vertices (or a target ) in a weighted graph with non-negative weights.
Dijkstra(G, w, s, t):
for each vertex v:
dist[v] = infinity
prev[v] = undefined
dist[s] = 0
S = empty set // finalised vertices
Q = all vertices // priority queue keyed by dist
while Q is not empty:
u = vertex in Q with minimum dist[u]
remove u from Q; add u to S
if u == t: break
for each neighbour v of u in Q:
if dist[u] + w(u, v) < dist[v]:
dist[v] = dist[u] + w(u, v)
prev[v] = u
// path: follow prev[] from t back to s
Idea: repeatedly pick the unvisited vertex with the smallest tentative distance, fix it as final, and relax its outgoing edges. With a binary heap the running time is ; with an array it is .
Example: edges - 4, - 1, - 2, - 5. From : , (via ), . Shortest path has length 8.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 5 marks
Using direct proof show that the sum of square of even number is even.
Similar questions: Using direct proof show that the (2081)
Answer
Claim: the square of an even number is even, and so the sum of squares of even numbers is even.
Direct proof. Let and be even integers: and for integers . Then
so each square is even. Their sum is
which is 2 times an integer, hence even. The same argument works for any number of even terms, since .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2081 · 5 marks
Using direct proof show that the sum of odd and even number is odd.
Similar questions: Using direct proof show that the (2080.1)
Answer
Claim: the sum of an odd integer and an even integer is odd.
Direct proof: Let be odd and be even. By definition, and for some integers . Then
Since is an integer, has the form with , so it is odd.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2082 · 5 marks
Find the shortest path from to in following graph using Dijkstra's algorithm.
Similar questions: Write the Dijkstra's algorithm to find (2079)
Answer
Dijkstra's algorithm: keep a distance label for every vertex (, others ). Repeatedly pick the unvisited vertex with the smallest label, mark it permanent, and relax its neighbours: . Stop when is permanent.
Applying it to the graph with edges :
| Step | Permanent vertex | |||||
|---|---|---|---|---|---|---|
| 0 | a (0) | 4 | 2 | |||
| 1 | c (2) | 3 | - | 10 | 12 | |
| 2 | b (3) | - | - | 8 | 12 | |
| 3 | d (8) | - | - | - | 10 | 14 |
| 4 | e (10) | - | - | - | - | 13 |
| 5 | z (13) |
Tracing predecessors back from : .
Shortest path: with length .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2078 · 10 marks
Explain direct proof, indirect proof, and proof by contradiction. Use direct proof to show that 'If is an odd integer, then is an odd integer'. Also use indirect proof to show that 'If is an integer and is odd, then is odd'.
Answer
Direct proof: to prove , assume is true and, using definitions, axioms and known theorems, show directly that is true.
Indirect proof (proof by contraposition): to prove , prove the equivalent contrapositive : assume is false and show is false.
Proof by contradiction: to prove , assume and derive a contradiction (or an impossible statement). For , assume and derive a contradiction. Hence must be true.
Direct proof: if is odd, then is odd.
Let be odd, so for some integer . Then
Since is an integer, is of the form , so is odd.
Indirect proof: if is odd, then is odd.
The contrapositive is: if is not odd (even), then is not odd (even). Let be even, so . Then
which is even. Thus the contrapositive is true, so the original statement holds: if is odd then is odd.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2078 · 10 marks
What is linear nonhomogeneous recurrence relation of degree with constant coefficients? Find all the solutions of the recurrence relation . Also find the solution of the relation with initial condition .
Answer
Definition: a linear nonhomogeneous recurrence relation of degree with constant coefficients has the form
where are real constants, , and is a function of only. The solution is : the general solution of the associated homogeneous relation plus a particular solution.
Solve .
Homogeneous part: has characteristic equation , so .
Particular solution: since is linear, try . Substituting:
Comparing coefficients: , so ; and , so , giving .
All solutions:
With : , so .
Check: and the formula gives .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2078 · 10 marks
Define spanning tree and minimum spanning tree with suitable example. Use Kruskal's algorithm to find minimum spanning tree in the given graph.
Answer
Spanning tree: a spanning tree of a connected graph is a subgraph that is a tree and contains all vertices of . For vertices it has exactly edges and no cycle.
Minimum spanning tree (MST): in a connected weighted graph, a spanning tree whose total edge weight is minimum.
Example: for a triangle with vertices and edges , , , the spanning trees are (weight 3), (4), (5). The MST is with weight 3.
Kruskal's algorithm:
- Sort the edges in non-decreasing order of weight.
- Take the smallest edge; add it to the tree if it does not form a cycle with edges already chosen; otherwise discard it.
- Repeat until edges are chosen.
Illustration on a graph with vertices and edges , , , , , , :
| Edge | Weight | Decision |
|---|---|---|
| 1 | Add | |
| 2 | Add | |
| 3 | Reject (cycle --) | |
| 4 | Add | |
| 5 | Reject (cycle) | |
| 6 | Add (4 edges reached) |
MST edges: with total weight .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2078 · 5 marks
What is tautology? Show is a tautology.
Answer
A tautology is a compound proposition that is true for all possible truth values of its component propositions.
Show is a tautology.
| T | T | T | T | T |
| T | F | F | T | T |
| F | T | F | T | T |
| F | F | F | F | T |
The last column is always true, so it is a tautology.
Algebraic check: .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2078 · 5 marks
Define cartesian product. Find for the set .
Answer
Cartesian product: for sets and , the Cartesian product is the set of all ordered pairs with and :
In general is the set of ordered -tuples with , and .
For , ordered triples:
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2078 · 5 marks
How can you represent relations using matrices? Suppose that and . Let be the relation from to containing if , , and . What matrix represents if , , , and , ?
Answer
Representing relations by matrices: let be a relation from to . The zero-one matrix of size has
Rows are indexed by elements of and columns by elements of .
For , and :
.
Row 1 is , row 2 is , row 3 is .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2078 · 5 marks
What is congruent modulo? Determine whether is congruent to modulo and is congruent to modulo .
Answer
Congruence modulo: let be integers and a positive integer. is congruent to modulo , written , if divides . Equivalently, and leave the same remainder when divided by .
(a) , and (). So : yes, congruent. (Both leave remainder 2.)
(b) , and . So : not congruent. (Remainders are 0 and 2.)
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2078 · 5 marks
Explain trial division with example? Using trial division, show that is prime.
Answer
Trial division: to test whether a positive integer is prime, divide it by every prime . If none divides , then is prime; if some prime divides it, is composite. This works because a composite number has a prime factor not exceeding .
Example: . ; primes up to 9 are 2, 3, 5, 7. Since , it is composite.
Show 101 is prime: , so test primes .
- : remainder 1.
- : , remainder 2.
- : remainder 1.
- : , remainder 3.
No prime up to divides 101, so 101 is prime.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2078 · 5 marks
Explain product rule. How many strings are there of four lowercase letters that have the letter in them?
Answer
Product rule: if a procedure can be broken into two tasks (or a sequence of tasks), where there are ways to do the first and ways to do the second after the first is done, then there are ways to do the procedure (in general ).
Example: a license code with one letter (26 ways) followed by one digit (10 ways) can be formed in ways.
Strings of four lowercase letters containing :
Count all strings and subtract those with no .
- Total strings of length 4: .
- Strings with no (letters from the other 25): .
There are strings that contain the letter at least once.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2078 · 5 marks
What is graph? Explain simple graph and pseudograph with example.
Answer
A graph consists of a non-empty set of vertices (nodes) and a set of edges, each edge connecting a pair of vertices. Graphs model networks such as roads, computer networks and social links.
Simple graph: an undirected graph with no loops (an edge from a vertex to itself) and no multiple (parallel) edges. Each edge is an unordered pair of distinct vertices.
Example: , is a simple graph (a 4-cycle).
Pseudograph: an undirected graph that may contain both multiple edges and loops. It is the most general type of undirected graph.
Example: with two parallel edges between and , an edge -, and a loop at . A loop adds 2 to the degree of its vertex, so .
| Type | Multiple edges | Loops |
|---|---|---|
| Simple graph | No | No |
| Multigraph | Yes | No |
| Pseudograph | Yes | Yes |
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2078 · 5 marks
What is Euler path? Compare it with Hamilton path.
Answer
Euler path: a path in a graph that uses every edge exactly once. If it starts and ends at the same vertex it is an Euler circuit.
Hamilton path: a path that visits every vertex exactly once (a Hamilton circuit also returns to the start).
| Basis | Euler path | Hamilton path |
|---|---|---|
| Visits | Every edge exactly once | Every vertex exactly once |
| Vertices | May be repeated | Not repeated |
| Edges | Not repeated | Need not all be used |
| Existence test | Simple: connected and 0 or 2 odd-degree vertices | No known simple necessary and sufficient condition (NP-complete) |
| Sufficient condition | Even degrees (circuit) | Dirac: for all () |
| Example use | Route inspection, mail delivery | Travelling salesman problem |
Example: in the complete graph every vertex has degree 3 (four odd vertices), so it has no Euler path, but it has a Hamilton circuit.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2079 · 10 marks
Give any four examples that are not propositions. Assume the premises, all over smart persons are stupid, children of stupid persons are naughty, John is over smart, Sam is children of John. Using rules of inferences, show that Sam is naughty.
Answer
Four statements that are not propositions (they are not definitely true or false):
- What is your name? (question)
- Close the door. (command)
- (truth depends on )
- How beautiful the Himalayas are! (exclamation)
Predicates: let : is over smart, : is stupid, : is a child of , : is naughty.
Premises:
Proof:
| Step | Statement | Reason |
|---|---|---|
| 1 | Premise | |
| 2 | Universal instantiation of 1 | |
| 3 | Premise | |
| 4 | Modus ponens (2, 3) | |
| 5 | Premise | |
| 6 | Conjunction (4, 5) | |
| 7 | Premise | |
| 8 | Universal instantiation of 7 | |
| 9 | Modus ponens (6, 8) |
Hence Sam is naughty.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2079 · 5+5 marks
Why do we need principle of inclusion and exclusion? How many ways can we express the four character words ending with a digit and beginning three are lowercase alphabets. Be sure that none of the character can be repeated. Using induction, show that is multiple of 2 for .
Answer
Need for the principle of inclusion and exclusion (PIE): when counting elements in a union of sets that overlap, simply adding the sizes counts common elements more than once. PIE corrects this:
Counting words: the first three characters are distinct lowercase letters and the fourth is a digit (a digit can never equal a letter, so no repetition issue there).
There are 156000 such words.
Induction: prove : is a multiple of 2 for .
Basis: : , which is divisible by 2.
Inductive step: assume for some integer . Then
which is a multiple of 2. By induction, is a multiple of 2 for all .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2079 · 4+6 marks
State necessary and sufficient conditions for a graph to have Euler path and circuit. Find the GCD of 12 and 18 using Extended Euclidian Algorithm.
Answer
Euler circuit: a connected graph (ignoring isolated vertices) has an Euler circuit if and only if every vertex has even degree.
Euler path (not a circuit): a connected graph has an Euler path if and only if it has exactly two vertices of odd degree; the path starts at one odd vertex and ends at the other. (With zero odd vertices an Euler circuit exists, which is also an Euler path.)
GCD of 12 and 18 by the Extended Euclidean Algorithm:
The last non-zero remainder is 6, so .
Back-substitute:
So with , .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2079 · 5 marks
Show that the sum of two even numbers is even using direct proof.
Answer
Claim: the sum of two even numbers is even.
Direct proof: let and be even integers. By definition, and for some integers . Then
Since is an integer, is 2 times an integer, so it is even.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2079 · 5 marks
Define power set. What is the power set of the set ?
Answer
Power set: the power set of a set is the set of all subsets of , including the empty set and itself. If then .
For , :
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2079 · 5 marks
Explain one-to-one correspondence with example. What is identity function?
Answer
One-to-one correspondence (bijection): a function that is both one-to-one (injective: ) and onto (surjective: every equals for some ). Every element of is paired with exactly one element of and vice versa, so for finite sets.
Example: , . If then (one-to-one); for any , gives (onto). So is a bijection. By contrast on is neither.
Identity function: defined by for all . It is a bijection and is its own inverse.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2079 · 5 marks
What is recursively defined function? Suppose that is defined recursively by , . Find , , , and .
Answer
A recursively defined function is defined in terms of its own values at smaller arguments: a basis step gives the value(s) at the starting point(s), and a recursive step gives a rule to compute later values from earlier ones.
Given and :
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2079 · 5 marks
What is arithmetic modulo ? Use the definition of addition and multiplication in to find and .
Answer
Arithmetic modulo : on , addition and multiplication are defined by
i.e. the remainder after division by .
For :
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2079 · 5 marks
Define equivalence relation with an example.
Answer
A relation on a set is an equivalence relation if it is
- Reflexive: for all ,
- Symmetric: ,
- Transitive: and .
Example: on , define iff (i.e. ).
- Reflexive: is divisible by 3.
- Symmetric: if then .
- Transitive: if and then .
So is an equivalence relation; it partitions into three equivalence classes (remainders 0, 1, 2).
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2079 · 5 marks
What is generalized pigeonhole principle? If a class has 24 students, what is the maximum number of possible grading that must be done to ensure that there at least two students with the same grade.
Answer
Generalized pigeonhole principle: if objects are placed into boxes, then at least one box contains at least objects.
Application: 24 students, with possible grades. At least two students share a grade when , i.e. when . If there were 24 or more grades, all students could have different grades. Hence the number of distinct grades must be at most ; with 23 grades (the maximum), , so at least two students are guaranteed the same grade.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080 · 10 marks
Explain how set operations can be represented using venn diagram with example. Convert the following sentences using quantifier: (a) Not all good peoples are heroes. (b) Every peoples in our country are loyal. (c) Some people hate good people.
Answer
Set operations with Venn diagrams: the universal set is drawn as a rectangle and each set as a circle inside it. Shading shows the result:
- Union : shade both circles entirely.
- Intersection : shade only the overlapping region.
- Difference : shade the part of outside .
- Complement : shade everything in outside .
Example: , , . Then , , , . In the diagram, 3 and 4 lie in the overlap, 1 and 2 in only, 5 and 6 in only, and 7 and 8 outside both circles.
Quantifier forms: let : is good, : is a hero, : is a person.
(a) Not all good people are heroes:
(b) Every person in our country is loyal (with : is loyal, domain = people of our country):
(c) Some people hate good people (with : hates ):
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080 · 5+5 marks
State ceiling function and floor function with examples. How mathematical induction can be used to prove the correctness of recursive algorithm? Illustrate with an example.
Answer
Floor function : the greatest integer less than or equal to . Examples: , , .
Ceiling function : the least integer greater than or equal to . Examples: , , .
Induction and recursive algorithms: a recursive algorithm solves a problem by calling itself on smaller inputs, with a base case. Its correctness is proved by induction on the input size: show the algorithm is correct for the base case (basis), then assume it is correct for all smaller inputs (inductive hypothesis) and show that the recursive step combines their results into a correct answer for the current input.
Example: recursive power function.
power(a, n): // a != 0, n >= 0
if n == 0: return 1
return a * power(a, n - 1)
Claim: for all .
Basis: returns .
Inductive step: assume . Then .
Hence the algorithm is correct for all (and terminates since decreases each call).
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080 · 4+6 marks
What does connectivity in graphs mean? Differentiate between permutation and combination. Solve the recurrence relation with initial conditions and .
Answer
Connectivity in graphs: an undirected graph is connected if there is a path between every pair of distinct vertices; otherwise it is disconnected and splits into connected components. A directed graph is strongly connected if there is a directed path from every vertex to every other, and weakly connected if the underlying undirected graph is connected. Connectivity also measures robustness: a cut vertex or bridge is one whose removal disconnects the graph.
Permutation vs combination:
| Permutation | Combination |
|---|---|
| Ordered arrangement of objects out of | Unordered selection of objects out of |
| Order matters | Order does not matter |
Also .
Recurrence: , , .
Characteristic equation: , so .
From : . From : . Subtracting twice the first: , so and .
Check: .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080 · 5 marks
Describe pre-order, postorder and inorder traversal of a tree with an example.
Answer
A tree traversal visits every vertex of an ordered rooted tree exactly once. For a binary tree with root , left subtree and right subtree :
- Pre-order: visit root, then , then (Root-Left-Right).
- In-order: traverse , visit root, then (Left-Root-Right).
- Post-order: traverse , then , visit root (Left-Right-Root).
Example tree: is the root with children (left) and (right); has children (left) and (right); has right child .
- Pre-order:
- In-order:
- Post-order:
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080 · 5 marks
Explain one-to-one and onto function with example. What is identity function?
Answer
One-to-one (injective) function: is one-to-one if different inputs give different outputs: . Example: on . Counter-example: on since .
Onto (surjective) function: is onto if every element of is the image of at least one element of (range = codomain). Example: from to . Counter-example: from to is not onto, since negative numbers are never obtained (it is onto ).
A function that is both is a bijection.
Identity function: with for all .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080 · 5 marks
How can you represent relations using matrices? Explain with suitable example.
Answer
A relation from to is represented by an zero-one matrix where
Example: , on :
Using the matrix to test properties:
- Reflexive: all diagonal entries are 1.
- Symmetric: (here it is symmetric).
- Antisymmetric: with implies .
Operations: union , intersection , and composition (Boolean product).
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080 · 5 marks
Prove that is irrational number.
Answer
Claim: is irrational.
Proof by contradiction. Suppose is rational. Then with integers , , and (fraction in lowest terms).
Squaring: , so . Hence is even, which implies is even (the square of an odd number is odd). Write .
Then , so , hence is even and is even.
Now both and are even, so 2 divides , contradicting . Therefore is irrational.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080 · 5 marks
Solve the system of following congruences using Chinese Remainder theorem: , ,
Answer
Solve , , .
The moduli are pairwise coprime, so CRT applies. .
, , .
Inverses with :
- , and , so .
- , so .
- , so .
So . Check: , , .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080 · 5 marks
What is the pigeonhole principle? Show that where and are positive integers with .
Answer
Pigeonhole principle: if or more objects are placed into boxes, then at least one box contains two or more objects. (Generalized: objects in boxes gives some box with at least objects.)
Pascal's identity: .
Algebraic proof:
Common denominator :
Combinatorial proof: choose items from items, one of which is a special item . Either is chosen (then choose more from the other : ways) or is not chosen (choose all from the other : ways).
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080 · 5 marks
What is permutation? What is the next permutation in lexicographic order after 362541?
Answer
A permutation is an ordered arrangement of the objects of a set; -permutations of objects number , and all objects can be arranged in ways.
Next permutation after 362541 (lexicographic order):
- From the right, find the first digit smaller than its right neighbour: the suffix is decreasing, and , so the pivot is 2.
- In the suffix pick the smallest digit larger than 2: it is 4. Swap: .
- Reverse the part after the pivot's position: .
Next permutation: 364125.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080 · 5 marks
Explain incidence matrix representation of a graph with example.
Answer
The incidence matrix of an undirected graph with vertices and edges is an matrix with
(A loop is shown by a 1 only once in its column; multiple edges give identical columns. For a directed graph, use at the tail and at the head.)
Example: , edges , , , :
Each column has exactly two 1s (the two endpoints of the edge), and each row sum equals the degree of the vertex (). It needs storage, so it is less compact than an adjacency list for sparse graphs.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080 · 5 marks
Define tree traversal. Explain pre-order traversal with example.
Answer
Tree traversal (tree walk) is the process of visiting every vertex of a rooted tree exactly once in a systematic order.
Pre-order traversal: visit the root first, then recursively traverse each subtree from left to right (Root, Left, Right).
preorder(T):
visit(root of T)
for each child subtree in left-to-right order:
preorder(subtree)
Example: root with children and ; has children and ; has child .
Pre-order: start at , go to , then , then , back up to , then .
Pre-order is used to copy a tree and to produce prefix (Polish) expressions.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 4 marks
What is Boolean matrix and list its operations?
Answer
A Boolean matrix (zero-one matrix) is a matrix whose entries are only 0 or 1. It is used, for example, to represent relations and graphs.
Operations for and of the same size:
- Join (OR): .
- Meet (AND): .
- Boolean product: for () and (), where .
- Boolean power: ( times).
- Also transpose and complement.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 2 marks
Differentiate between graph and tree.
Answer
| Graph | Tree |
|---|---|
| May contain cycles | Connected and has no cycles |
| May be connected or disconnected | Always connected |
| Any number of edges | Exactly edges for vertices |
| Several paths may exist between two vertices | Exactly one path between any two vertices |
| No root needed | May be rooted (hierarchical) |
Every tree is a graph, but not every graph is a tree.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 8 marks
Describe about the necessary conditions for graphs to be isomorphic with an example.
Answer
Two simple graphs and are isomorphic if there is a bijection such that are adjacent in if and only if are adjacent in . No simple test is known to prove isomorphism, but there are easy necessary conditions (invariants). If any one fails, the graphs are not isomorphic:
- The same number of vertices.
- The same number of edges.
- The same degree sequence (the multiset of vertex degrees).
- The same number of vertices of each degree; a vertex of degree must map to a vertex of degree .
- The same number of cycles of each length (e.g. both have triangles or neither does), and the same circuit structure.
- Same connectivity: both connected or both disconnected, with the same number of components.
- Adjacency structure preserved: neighbours of a vertex must map to neighbours of its image (e.g. adjacent vertices of degree 3 map to adjacent vertices of degree 3).
- Equivalently, adjacency matrices must be identical after suitably relabelling vertices.
These conditions are necessary but not sufficient; after they hold, one must exhibit the mapping and check edges.
Example: : vertices with edges . : vertices with edges . Both have 4 vertices, 4 edges and degree sequence . Define , , , . Edges map to , exactly the edge set of , so .
Non-example: a 4-cycle and a star both have 4 vertices, but has 4 edges and only 3, so they are not isomorphic. Also the path (degrees ) and (degrees ) have the same number of edges (3) but different degree sequences.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 3 marks
Define randomized algorithm with an example.
Answer
A randomized algorithm makes random choices (random numbers) during execution, so its behaviour or running time may differ between runs on the same input. Two kinds: Las Vegas (always correct, running time random) and Monte Carlo (running time fixed, answer correct with high probability).
Example: randomized quicksort. Choose the pivot uniformly at random from the sub-array, partition around it, and recurse on both parts. Because no fixed input can force bad pivots consistently, the expected running time is for every input, avoiding the worst case on already sorted data. The output is always a correctly sorted array (Las Vegas).
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 7 marks
Solve the recurrence relation for , with initial condition and .
Answer
, , .
Characteristic equation: , so (repeated root).
General solution:
Using : .
Using : .
Check: and the formula gives .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 5 marks
List the negations of following statements: (a) He has passed the exam. (b) All dogs are loyal. (c) Some medicine has side effect. (d) If you study then you will pass the exam. (e) Open the door.
Answer
(a) "He has passed the exam." Negation: He has not passed the exam (He failed the exam).
(b) "All dogs are loyal." . Negation: , i.e. some dog is not loyal.
(c) "Some medicine has side effect." . Negation: , i.e. no medicine has a side effect.
(d) "If you study then you will pass the exam." . Negation: , i.e. you study and you will not pass the exam.
(e) "Open the door." This is a command, not a proposition, so it has no truth value and no logical negation. Its opposite instruction is "Do not open the door."
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 5 marks
How does Kruskal algorithm work? Illustrate with an example.
Answer
Kruskal's algorithm finds a minimum spanning tree of a connected weighted graph by the greedy method.
Steps:
- Sort all edges in non-decreasing order of weight.
- Start with an empty edge set (each vertex is its own component).
- Take the next smallest edge; add it to if it does not form a cycle with edges already in (its endpoints are in different components), otherwise discard it.
- Stop when has edges.
Cycle checks are done with a union-find structure. Time: .
Example: vertices with edges , , , , , , .
| Edge | Weight | Decision |
|---|---|---|
| 1 | Add | |
| 2 | Add | |
| 3 | Add (joins and ) | |
| 4 | Reject (cycle) | |
| 5 | Add (now 4 edges, done) |
MST edges: with total weight .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 5 marks
State generalized Pigeonhole principle. How many ways can we get the 3 digit integers without repeating the digit?
Answer
Generalized pigeonhole principle: if objects are placed into boxes, then some box contains at least objects.
3-digit integers without repeating a digit: the hundreds digit cannot be 0, so there are 9 choices; the tens digit can be any of the remaining 9 digits (including 0); the units digit has 8 choices.
There are 648 such integers.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 5 marks
Define equivalence relation. How do you represent relation?
Answer
A relation on a set is an equivalence relation if it is reflexive ( for all ), symmetric () and transitive (). Example: "has the same remainder when divided by 4" on ; it partitions into equivalence classes.
Representing relations:
- Roster (set of ordered pairs): on .
- Zero-one matrix: entry if :
- Directed graph (digraph): each element is a vertex and each pair is a directed edge from to ; a pair is a loop. For the relation above: loops on 1, 2, 3 and arrows .
- Rule/set-builder form: .
- Table: rows and columns labelled by elements, marked where related.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 5 marks
How do you solve computer arithmetic with large integers using Chinese remainder theorem? Give an example.
Answer
Chinese Remainder Theorem (CRT): if are pairwise coprime, the system has a unique solution modulo .
Large-integer arithmetic: choose pairwise coprime moduli whose product exceeds the largest result expected. Represent each large integer by its tuple of remainders . Addition, subtraction and multiplication are then done component-wise on small numbers (each in its own modulus), with no carries between components, which is fast and parallelisable. Finally, CRT reconstructs the actual result from the remainders.
Example: compute using moduli ().
- , .
- Component-wise sum: .
Solve , , with and inverses , , :
So , as expected.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 5 marks
Write Dijkstra's algorithm to find the shortest path from source node to goal node.
Answer
Dijkstra's algorithm computes shortest paths from a source node to the other nodes of a weighted graph with non-negative edge weights, and so gives the shortest path to a goal node .
Dijkstra(G, w, s, g):
for each vertex v in G:
dist[v] = infinity
prev[v] = none
dist[s] = 0
Q = set of all vertices
while Q is not empty:
u = vertex in Q with smallest dist[u]
remove u from Q
if u == g: break // shortest path to goal found
for each neighbour v of u still in Q:
alt = dist[u] + w(u, v)
if alt < dist[v]:
dist[v] = alt
prev[v] = u
path = []
u = g
while u is not none:
insert u at front of path
u = prev[u]
return path, dist[g]
Working: the vertex with the smallest tentative distance is permanently labelled, then its neighbours' distances are relaxed (updated if a shorter route is found via it). Repeating this expands outward from . Complexity is with an array and with a binary heap.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 5 marks
How do you plot graph for function ? Define ceiling, floor and exponential function.
Answer
Plotting :
- Make a table of values:
- Plot points on the Cartesian plane: , , , , .
- Join them with a straight line. It is a line of slope 1 with -intercept 1 and -intercept .
Definitions:
- Floor: is the largest integer (e.g. , ).
- Ceiling: is the smallest integer (e.g. , ).
- Exponential function: with base , (commonly or ). It is always positive, passes through , and grows rapidly for . Example: .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2080.1 · 5 marks
List any five rules of inferences.
Answer
Rules of inference are valid argument forms used to derive a conclusion from premises. Five common ones:
- Modus ponens:
- Modus tollens:
- Hypothetical syllogism:
- Disjunctive syllogism:
- Addition:
Other rules are simplification (), conjunction () and resolution ().
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2081 · 5+5 marks
Define graph isomorphism with an example. Using Kruskal's algorithm generate the Minimum Spanning Tree from following graph.
Answer
Graph isomorphism
Two simple graphs and are isomorphic if there is a one-to-one and onto function such that and are adjacent in if and only if and are adjacent in . Isomorphic graphs have the same number of vertices, edges, the same degree sequence and the same cycles.
Example: has vertices and edges (a 4-cycle). has vertices and edges . The function maps every edge of onto an edge of and vice versa, so .
Kruskal's algorithm (Minimum Spanning Tree)
- Sort all edges in non-decreasing order of weight.
- Start with an empty edge set .
- Take the next smallest edge; add it to if it does not form a cycle with edges already in , otherwise discard it.
- Stop when has edges ( = number of vertices).
Illustration (graph with edges ):
| Edge | Weight | Action |
|---|---|---|
| ab | 1 | accept |
| bc | 2 | accept |
| ac | 3 | reject (cycle a-b-c) |
| cd | 4 | accept |
| bd | 5 | reject (cycle) |
| de | 6 | accept |
has 4 edges for 5 vertices, so it is the MST with total weight .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2081 · 2+8 marks
What are the uses of randomized algorithm? Find the solution to the recurrence relation with the initial conditions , and .
Answer
Uses of randomized algorithms
- They are usually simpler and faster than deterministic ones (e.g. randomized quicksort avoids the worst case on sorted input).
- They give good expected running time for hard problems such as primality testing (Miller-Rabin), min-cut and hashing.
- They are used in cryptography (random keys), simulation, Monte Carlo methods and load balancing.
Recurrence
Characteristic equation: , i.e. , so .
Using the initial conditions:
Subtracting consecutive equations: and , so . Hence , , .
Check: , , .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2081 · 6+4 marks
Define Boolean function, exponential function and partial ordering. List the computer representations for following set over universal set : (a) Set that contains even number (b) Set that contains multiple of 5 (c) Set that contains number greater than 7 (d) Set that contains prime number.
Answer
Boolean function: a function that assigns 0 or 1 to every combination of Boolean variables, e.g. .
Exponential function: a function of the form with constant base (e.g. , ), where the variable appears in the exponent.
Partial ordering: a relation on a set that is reflexive, antisymmetric and transitive. The pair is a partially ordered set (poset), e.g. on integers or divisibility on positive integers.
Computer (bit-string) representation over , where bit is 1 if is in the set:
(a) Even numbers :
(b) Multiples of 5 :
(c) Numbers greater than 7 :
(d) Primes :
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2081 · 5 marks
Define proposition. Convert the following sentences to predicate: (a) Some kind hearted peoples do still exist. (b) Student who study hard and do the homework get good marks in exam.
Answer
Proposition: a declarative sentence that is either true or false, but not both. For example, "Kathmandu is the capital of Nepal" is a proposition; "Close the door" and "What is your name?" are not.
Predicate forms
(a) Let : " is kind hearted", with the domain of all people. "Some kind hearted people still exist" is
(b) Let : " is a student", : " studies hard", : " does the homework", : " gets good marks in the exam".
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2081 · 5 marks
Prove that is a perfect square using mathematical induction.
Answer
Claim: , which is the square of the integer , hence a perfect square.
Basis step: : LHS , RHS . True.
Inductive step: Assume is true:
Then
which is , i.e. .
By mathematical induction holds for all , so the sum is always a perfect square.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2081 · 5 marks
Find the multiplicative inverse of 6 in using Extended Euclidean Algorithm.
Answer
We need with . First, , so the inverse exists.
Euclidean steps:
The gcd is 1. Back-substitute:
So the coefficient of 6 is , and .
Check: .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2081 · 5 marks
State generalized Pigeonhole principle. How many ways can you draw four digits integers without repetition of the digit?
Answer
Generalized pigeonhole principle: if objects are placed into boxes, then at least one box contains at least objects.
Four-digit integers without repetition of digits
The first digit cannot be 0, so it has 9 choices (1-9). The second digit can be any of the remaining 9 digits (including 0), the third has 8 choices and the fourth has 7.
So 4536 such integers can be formed.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2081 · 5 marks
Explain any two ways of representing the graph.
Answer
Two common ways to represent a graph with vertices:
1. Adjacency list: for each vertex store a list of the vertices adjacent to it.
For the graph with edges :
| Vertex | Adjacent vertices |
|---|---|
| a | b, c |
| b | a, c |
| c | a, b, d |
| d | c |
It uses space and is efficient for sparse graphs.
2. Adjacency matrix: an matrix where if there is an edge from to , and 0 otherwise (for weighted graphs, store the weight). For the same graph (order a, b, c, d):
For an undirected graph the matrix is symmetric. It needs space but allows checking an edge in time.
(Incidence matrix, an matrix of vertex-edge incidence, is a third option.)
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2081 · 5 marks
Compute the value of , , , and .
Answer
is the remainder with and .
- , since .
- , since .
- , since .
- , since .
- , since .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2081 · 5 marks
Define cut vertices and cut edges. How do you determine whether the graph has Euler path?
Answer
Cut vertex (articulation point): a vertex whose removal (together with its incident edges) increases the number of connected components of the graph.
Cut edge (bridge): an edge whose removal increases the number of connected components.
Euler path: a path that uses every edge of the graph exactly once. For a connected graph:
- The graph has an Euler path (not closed) if and only if it has exactly two vertices of odd degree; the path starts at one odd vertex and ends at the other.
- If all vertices have even degree, the graph has an Euler circuit, which is also an Euler path (closed).
- If it has more than two odd-degree vertices, no Euler path exists.
So count the degrees: 0 or 2 odd-degree vertices (in a connected graph) means an Euler path exists. For a directed graph, at most one vertex has out-degree minus in-degree , at most one has in-degree minus out-degree , and all others have equal in- and out-degree.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2081 · 5 marks
Explain about structural induction and recursive definitions with example.
Answer
Recursive definition: defines an object in terms of smaller instances of itself, using a basis (initial) case and a recursive step.
Example (factorial): (basis); for (recursive step).
Example (set of strings): the set of strings over alphabet : the empty string ; if and then .
Structural induction: a proof technique for recursively defined structures (strings, trees, formulas). To prove holds for all elements:
- Basis step: show holds for the elements specified in the basis.
- Recursive step: show that if holds for the elements used to construct a new element, then holds for the new element.
Example: a full binary tree is defined by: a single vertex is a full binary tree (height 0, 1 vertex); if are full binary trees, joining their roots under a new root gives a full binary tree. Claim . Basis: one vertex, . Step: where and . So the claim holds for all full binary trees.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2082 · 2+8 marks
State division theory. Add two integers and using Chinese Remainder Theorem.
Answer
Division theorem: for any integer and positive integer there exist unique integers (quotient) and (remainder) with such that .
Adding with the Chinese Remainder Theorem
The sum is below , so choose pairwise coprime moduli whose product exceeds it: , with .
Residues:
| Modulus | Sum mod | ||
|---|---|---|---|
| 99 | 15 | 91 | |
| 98 | 54 | 62 | |
| 97 | 95 | 43 | |
| 95 | 88 | 35 |
So we solve .
With and :
| 99 | 903070 | 37 |
| 98 | 912285 | 33 |
| 97 | 921690 | 24 |
| 95 | 941094 | 4 |
Check by direct addition: .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2082 · 2+3+5 marks
Why do we need quantifiers? List any three rules of inferences. Prove that is irrational using prove by contradiction.
Answer
Need for quantifiers: propositional logic cannot express statements about all or some members of a domain, such as "every student passes" or "some integer is prime". Quantifiers ( universal, existential) let a predicate be turned into a proposition about a whole domain, which is needed for precise mathematical statements and reasoning.
Three rules of inference
- Modus ponens:
- Modus tollens:
- Hypothetical syllogism:
Proof that is irrational (by contradiction)
Assume is rational. Then with integers , , and .
Squaring: , so . Hence is even, so is even; write .
Then , so , which makes even and so even.
Both and are even, contradicting . Hence the assumption is false and is irrational.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2082 · 2+4+4 marks
List some advantages of randomized algorithm. Given any set of ten natural numbers between and inclusive, prove that there are two disjoint nonempty subsets of the set with equal sums of their elements. How do you generalize permutations and combinations?
Answer
Advantages of randomized algorithms
- Simple to design and implement compared with deterministic algorithms for the same problem.
- Good expected running time; no particular input can force the worst case (e.g. randomized quicksort).
- Often faster and use less memory for hard problems (primality testing, hashing, min-cut).
- Useful in cryptography and simulation.
Disjoint subsets with equal sums
Let be a set of ten natural numbers from 1 to 99. It has nonempty subsets. The sum of any subset is at least 1 and at most the sum of the ten largest allowed numbers:
So there are only 945 possible sums for 1023 subsets. By the pigeonhole principle two different subsets have the same sum.
If and overlap, remove the common elements from both: the sums stay equal. Neither remaining set can be empty: if were empty then and would have sum 0, which is impossible since all numbers are positive. So we get two disjoint nonempty subsets with equal sums.
Generalizing permutations and combinations
- Permutations with repetition: ordered selections of objects from types.
- Permutations of objects with identical objects of each type: .
- Combinations with repetition: ways to choose objects from types.
These reduce to and when repetition is not allowed.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2082 · 5 marks
Mention the necessary and sufficient conditions for Euler path and Euler circuit with example.
Answer
An Euler path is a path that uses every edge exactly once; an Euler circuit is such a path that starts and ends at the same vertex.
Euler circuit: a connected multigraph has an Euler circuit if and only if every vertex has even degree.
Euler path (not a circuit): a connected multigraph has an Euler path but no Euler circuit if and only if it has exactly two vertices of odd degree. The path starts at one odd vertex and ends at the other.
Examples
- A square (4-cycle) : every vertex has degree 2 (even), so it has an Euler circuit .
- A square with one diagonal : degrees are ; exactly two odd vertices, so it has an Euler path starting at and ending at , e.g. , but no Euler circuit.
- has all degrees 3 (four odd vertices), so neither exists.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2082 · 5 marks
How do you represent set? Explain.
Answer
A set is an unordered collection of distinct objects. It can be represented in several ways:
1. Roster (tabular) method: list the elements inside braces. . For long sets an ellipsis is used: .
2. Set-builder (rule) method: describe a property common to all elements. .
3. Venn diagram: the universal set is drawn as a rectangle and each set as a closed curve (circle) inside it, with elements shown as points.
4. Recursive definition: give initial elements and a rule to generate others, e.g. , and if and then .
5. Computer (bit-string) representation: for a universal set in a fixed order, a subset is a bit string of length with bit equal to 1 if is in the set. For , is . Union, intersection and complement become bitwise OR, AND and NOT.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2082 · 5 marks
Solve the recurrence relation with initial conditions and .
Answer
Characteristic equation: , so
Let , . The general solution is .
Initial conditions:
This gives the Fibonacci numbers
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2082 · 2+3 marks
Define Boolean and exponential function. Discuss about partial ordering.
Answer
Boolean function: a function mapping Boolean variables to 0 or 1, built from AND, OR and NOT, e.g. .
Exponential function: a function with constant base ; the variable is in the exponent, e.g. or .
Partial ordering: a relation on a set that is reflexive (), antisymmetric ( and imply ) and transitive ( and imply ). is called a partially ordered set (poset). Not every pair of elements need be comparable. Examples: on the integers; divisibility on positive integers (2 and 3 are incomparable); on subsets of a set. Posets are drawn as Hasse diagrams.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2082 · 5 marks
Prove the correctness of following recursive algorithm for computing using induction:
Power(a, n) {
if (n = 0) return 1;
else return a * Power(a, n-1);
}
Power(a, n) {
if (n = 0) return 1;
else return a * Power(a, n-1);
}
Answer
Claim: Power(a, n) returns for every integer .
Proof by induction on .
Basis (): the condition n = 0 is true, so the function returns . Correct.
Inductive hypothesis: assume Power(a, k) returns for some .
Inductive step (): since , the else branch runs and returns a * Power(a, k). By the hypothesis this equals .
So the algorithm is correct for . By induction, Power(a, n) returns for all . It also terminates, because each call reduces by 1 until the base case is reached.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2082 · 2+3 marks
Define spanning and minimum spanning tree? How do you traverse tree?
Answer
Spanning tree: a spanning tree of a connected graph is a subgraph that is a tree (connected, no cycles) and contains all the vertices of ; it has edges.
Minimum spanning tree (MST): in a weighted connected graph, the spanning tree whose sum of edge weights is the smallest. It can be found with Kruskal's or Prim's algorithm.
Tree traversal means visiting every vertex of a rooted tree exactly once. For an ordered rooted tree there are three standard methods (T = root, with subtrees ):
- Preorder: visit the root, then traverse each subtree in preorder, left to right.
- Inorder (binary tree): traverse the left subtree, visit the root, then traverse the right subtree.
- Postorder: traverse the subtrees left to right, then visit the root.
For a binary tree with root , left child and right child : preorder is ; inorder is ; postorder is .
In general graphs, breadth-first and depth-first search are used.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2082 · 1+4 marks
What do you mean by connectivity in graph? Discuss about Bipartite and Planar graph.
Answer
Connectivity: an undirected graph is connected if there is a path between every pair of distinct vertices. Otherwise it splits into connected components. (A directed graph is strongly connected if there is a directed path from to and from to for all pairs.)
Bipartite graph: a graph whose vertex set can be split into two disjoint sets such that every edge joins a vertex in to a vertex in (no edge inside a set). Equivalently, its vertices can be coloured with two colours so that adjacent vertices differ, which holds exactly when the graph has no odd cycle. The complete bipartite graph has all edges between the sets. Example: is bipartite, is not.
Planar graph: a graph that can be drawn in the plane with no edges crossing. Properties for a connected planar graph with vertices, edges and regions:
- Euler's formula: .
- If : ; if there are no triangles, .
and are non-planar, and by Kuratowski's theorem a graph is planar iff it contains no subdivision of or .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
Questions from TU BIT 2078 Second Semester Microprocessor and Computer Architecture (TU IOST semester board exam, 2078 (BS), via StudyNp), TU BIT 2079 Second Semester Microprocessor and Computer Architecture (TU IOST semester board exam, 2079 (BS), via StudyNp), TU BIT 2080 Second Semester Microprocessor and Computer Architecture (TU IOST semester board exam, 2080 (BS), via StudyNp), TU BIT 2080.1 Second Semester Microprocessor and Computer Architecture (TU IOST semester board exam, 2080.1 (BS), via StudyNp), TU BIT 2081 Second Semester Microprocessor and Computer Architecture (TU IOST semester board exam, 2081 (BS), via StudyNp), TU BIT 2082 Second Semester Microprocessor and Computer Architecture (TU IOST semester board exam, 2082 (BS), via StudyNp), TU BIT 2078 Second Semester Discrete Structure (TU IOST semester board exam, 2078 (BS), via StudyNp), TU BIT 2079 Second Semester Discrete Structure (TU IOST semester board exam, 2079 (BS), via StudyNp), TU BIT 2080 Second Semester Discrete Structure (TU IOST semester board exam, 2080 (BS), via StudyNp), TU BIT 2080.1 Second Semester Discrete Structure (TU IOST semester board exam, 2080.1 (BS), via StudyNp), TU BIT 2081 Second Semester Discrete Structure (TU IOST semester board exam, 2081 (BS), via StudyNp), TU BIT 2082 Second Semester Discrete Structure (TU IOST semester board exam, 2082 (BS), via StudyNp), TU BIT 2078 Second Semester Object Oriented Programming (TU IOST semester board exam, 2078 (BS), via StudyNp), TU BIT 2079 Second Semester Object Oriented Programming (TU IOST semester board exam, 2079 (BS), via StudyNp), TU BIT 2080 Second Semester Object Oriented Programming (TU IOST semester board exam, 2080 (BS), via StudyNp), TU BIT 2081 Second Semester Object Oriented Programming (TU IOST semester board exam, 2081 (BS), via StudyNp), TU BIT 2078 Second Semester Economics (TU IOST semester board exam, 2078 (BS), via StudyNp), TU BIT 2079 Second Semester Economics (TU IOST semester board exam, 2079 (BS), via StudyNp), TU BIT 2080 Second Semester Economics (TU IOST semester board exam, 2080 (BS), via StudyNp), TU BIT 2080.1 Second Semester Economics (TU IOST semester board exam, 2080.1 (BS), via StudyNp), TU BIT 2078 Second Semester Basic Statistics (TU IOST semester board exam, 2078 (BS), via StudyNp), TU BIT 2079 Second Semester Basic Statistics (TU IOST semester board exam, 2079 (BS), via StudyNp), TU BIT 2080 Second Semester Basic Statistics (TU IOST semester board exam, 2080 (BS), via StudyNp) and TU BIT 2080.1 Second Semester Basic Statistics (TU IOST semester board exam, 2080.1 (BS), via StudyNp). Answers are written for this site; check them against your class notes.