100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Other

COS2611 Assignment 3 memo 2024

Rating
4,0
(1)
Sold
7
Pages
14
Uploaded on
14-08-2024
Written in
2024/2025

COS2611 Assignment 3 memo 2024 UNISA  2024  COS2611-24-Y  Assessment 3 QUIZ Question 1 Match the following operations on a Binary Search Tree (BST) with their correct descriptions: InsertionAdding a new node with a given value to the appropriate position in the BST while maintaining the BST properties. Inorder TraversalA process of visiting all nodes in a BST in ascending order of their values. DeletionRemoving a node with a specific value from the BST while ensuring that the tree remains a valid BST. SearchLooking for a node with a specific value in the BST and returning whether it exists or not. Question 2 Not yet answered Marked out of 1.00 Given the following sequence of numbers: [15, 7, 23, 4, 10, 18, 28], if you construct a binary search tree by inserting each number in the given order, what would be the root of the resulting tree? a. 15 b. 7 c. 23 d. 4 Clear my choiceQuestion 3 Not yet answered Marked out of 2.00 Consider the BST: If you perform an inorder traversal on this binary search tree, what would be the correct sequence of visited nodes? a. 3, 5, 10, 15, 20, 25 b. 10, 5, 3, 20, 15, 25 c. 3, 5, 15, 10, 20, 25 d. 10, 5, 15, 20, 3, 25 Clear my choiceQuestion 4 Not yet answered Marked out of 2.00 Consider the following binary search tree (BST): If you want to delete the node with the value 7 while maintaining the BST properties, what would be the resulting tree? a. b. c. d. Clear my choice Question 5 Not yet answered Marked out of 1.00 In the context of binary trees and tree traversal in C++, which traversal algorithm visits the nodes in the following order: left subtree, root, right subtree? a. Preorder traversal b. Inorder traversal c. Postorder traversal d. Level-order traversal UNISA  2024  COS2611-24-Y  Assessment 3 QUIZQuestion 12 Not yet answered Marked out of 8.00 Company XFiber, is requested by the municipality to install fiber in a new neighbourhood. The company is constrained to bury the fiber cable only along certain paths. Some of the paths might be more expensive. The cost is represented as a weight on the edge. You need to write a C++ program that will determine the minimum spanning tree that will represent the least expensive path for laying the fiber cable. To solve the above problem for Company XFibre, you may use AI (artificial intelligence) to help. As you are aware AI tools are becoming a valuable tool to help programmers in saving valuable time in the development of code for specific problems. Use an AI tool and generate C++ code that will implement Prim’s algorithm using ADT with a time complexity of O(n^2). Before you continue, whatch this video: After you have downloaded the code from the AI tool, you will need to make some changes. This is important that you add the following in your code - without it - the project will not be marked. 1. Insert as a comment your student name and number. 2. Add as a comment the question(s) that you have asked the AI tool to generate the code. 3. Add as comments in your code, the updates and changes that you are making. This is important as the marker needs to see your input, changes, and updates to the code to make it work for this case study. Adapt the code to allow you to read from a text file the test data. To test your code, create a text file () as displayed in the following image. The marker will use a different set of data to test your code. The code must read from c:data The first value represents the number of vertices, and the second value is the number of edges. The values thereafter represent combinations of (vertex, edge, and weight).The output of your code should list the minimum spanning tree paths. Example of output: Save your C++ solution as A3P, and replace with your student number. Upload the .cpp file. The following rubric will be used in marking the project:Maximum file size: 50 MB, maximum number of files: 1   Files  You can drag and drop files here to add them. Accepted file types Text file .cpp  UNISA  2024  COS2611-24-Y  Assessment 3 QUIZ Question 6 Answer saved Marked out of 5.00 Match the following traversal methods with their descriptions: Visits nodes in the order of root, left subtree, right subtree.Preorder Traversal Visits nodes level by level, starting from the root.Breadth-First Traversal (BFS) Visits nodes in the order of left subtree, root, right subtree.Inorder Traversal Visits nodes in the order of left subtree, right subtree, root.Postorder Traversal Explores as far as possible along each branch before backtracking.Depth-First Traversal (DFS)Question 7 Answer saved Marked out of 2.00 Given the directed graph with vertex set V(G) = {0, 1, 2, 3, 4, 5} and edge set E(G) = {(0,1), (1,2), (2,5), (3,1), (2,4), (4,3), (4,0)}, which of the following graphs correctly describe the relationship of the vertices for a directed graph? a. b. c. d. Clear my choiceQuestion 8 Answer saved Marked out of 2.00 Given the directed graph with vertex set V(G) = {0, 1, 2, 3, 4, 5} and edge set E(G) = {(0,1), (1,2), (2,5), (3,1), (2,4), (4,3), (4,0)}, which of the following represents the adjacency matrix? a. b. c. d. Clear my choiceQuestion 9 Answer saved Marked out of 1.00 Consider a scenario where you have a std::vector<int> named numbers containing the values [10, 20, 30, 40, 50]. You need to use an iterator to find and print the sum of all the elements in the vector. Which code snippet accomplishes this task correctly ? a. vector<int> numbers = { 10,20,30,40,50 }; int sum = 0; for (int num : numbers) { sum += num; } b. vector<int> numbers = { 10,20,30,40,50 }; int sum = 0; for (auto it = (); it != (); ++it) { sum += *it; } c. vector<int> numbers = { 10,20,30,40,50 }; int sum = 0; for (unsigned int i = 0; i < (); ++i) { sum += numbers[i]; } d. vector<int> numbers = { 10,20,30,40,50 }; int sum = 0; for (auto& num : numbers) { sum += num; } Clear my choice Question 10 Answer saved Marked out of 1.00 True or False? In C++, iterators provide a way to access and manipulate the elements of a container without exposing the underlying data structure. True FalseQuestion 11 Answer saved Marked out of 1.00 True or False? In a connected graph, a minimal spanning tree is a subset of the original graph's edges that connects all the vertices while having the lowest possible sum of edge weights. True False

Show more Read less









Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
August 14, 2024
Number of pages
14
Written in
2024/2025
Type
Other
Person
Unknown

Subjects

Content preview

UNISA  2024  COS2611-24-Y  Assessment 3

QUIZ




Started on Tuesday, 13 August 2024, 8:59 PM
State Finished
Completed on Wednesday, 14 August 2024, 9:20 PM
Time taken 1 day
Grade Not yet graded

Information




This is a compulsory assessment. You have one (1) attempt to complete the assessment. The system will automatically
upload your attempts when the due date and time is reached. The due date is 26 August 2024, 23:00.


Remember, the due date is the last date for submission and not the day on which you should start with the assessment.


There are 12 question in this assessment. Questions 1 - 11 are quiz questions. Question 12 is a practical project that you
have to complete and submit online.




Question 1

Correct

Mark 4.00 out of 4.00




Match the following operations on a Binary Search Tree (BST) with their correct descriptions:


Adding a new node with a given value to the appropriate position in the BST while maintaining the BST properties.
Insertion

Inorder A process of visiting all nodes in a BST in ascending order of their values.
Traversal

Removing a node with a specific value from the BST while ensuring that the tree remains a valid BST.
Deletion

Looking for a node with a specific value in the BST and returning whether it exists or not.
Search




Your answer is correct.
The correct answer is:
Insertion → Adding a new node with a given value to the appropriate position in the BST while maintaining the BST
properties.,

Inorder Traversal → A process of visiting all nodes in a BST in ascending order of their values.,

Deletion → Removing a node with a specific value from the BST while ensuring that the tree remains a valid BST.,

Search → Looking for a node with a specific value in the BST and returning whether it exists or not.

, Question 2

Correct

Mark 1.00 out of 1.00




Given the following sequence of numbers: [15, 7, 23, 4, 10, 18, 28], if you construct a binary search tree by inserting each
number in the given order, what would be the root of the resulting tree?


a. 15 

b. 7

c. 23

d. 4




Your answer is correct.

The correct answer is:
15




Question 3
Correct

Mark 2.00 out of 2.00




Consider the BST:




If you perform an inorder traversal on this binary search tree, what would be the correct sequence of visited nodes?


a. 3, 5, 10, 15, 20, 25 

b. 10, 5, 3, 20, 15, 25

c. 3, 5, 15, 10, 20, 25

d. 10, 5, 15, 20, 3, 25




Your answer is correct.

The correct answer is:
3, 5, 10, 15, 20, 25

Reviews from verified buyers

Showing all reviews
1 year ago

4,0

1 reviews

5
0
4
1
3
0
2
0
1
0
Trustworthy reviews on Stuvia

All reviews are made by real Stuvia users after verified purchases.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
CrystalIndigo University of South Africa (Unisa)
View profile
Follow You need to be logged in order to follow users or courses
Sold
486
Member since
5 year
Number of followers
226
Documents
73
Last sold
2 months ago
CrystalIndigo Solutions

providing all solutions to all computer science modules

4,1

51 reviews

5
27
4
13
3
6
2
1
1
4

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions