100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4,6 TrustPilot
logo-home
Exam (elaborations)

COS3711 Computer Science Assignment 2 – Full 2025 Detailed Solutions and Distinction-Level Answer Guide

Rating
-
Sold
-
Pages
17
Grade
A+
Uploaded on
17-07-2025
Written in
2024/2025

COS3711 Computer Science Assignment 2 – Full 2025 Detailed Solutions and Distinction-Level Answer Guide Introduction This document provides detailed, distinction-level solutions for COS3711 Computer Science Assignment 2 for the 2025 academic year. It includes 100 carefully crafted questions and answers, focusing on core concepts such as data structures, algorithms, object-oriented programming, and advanced C++ programming techniques. The solutions are concise, clear, and designed to help students achieve high marks while understanding key concepts. Each question is highlighted in very dark green and accompanied by a detailed explanation and, where applicable, C++ code snippets to illustrate implementation Assignment Questions and Solutions Below are 100 questions and solutions tailored to COS3711 Assignment 2, covering essential topics in advanced C++ programming and computer science concepts.

Show more Read less
Institution
Graduation In Computer Science
Course
Graduation in computer science










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

Written for

Institution
Graduation in computer science
Course
Graduation in computer science

Document information

Uploaded on
July 17, 2025
Number of pages
17
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

COS3711 Computer Science Assignment 2 –
Full 2025 Detailed Solutions and
Distinction-Level Answer Guide



Contents
1 Introduction 2

2 Assignment Questions and Solutions 2
2.1 Question 1: Implementing a Binary Search Tree . . . . . . . . . . . . 2
2.2 Question 2: Dynamic Programming - 0/1 Knapsack Problem . . . . . 4
2.3 Question 3: Stack Implementation Using Arrays . . . . . . . . . . . . 5
2.4 Question 4: Queue Implementation Using Linked List . . . . . . . . . 6
2.5 Question 5: QuickSort Algorithm . . . . . . . . . . . . . . . . . . . . . . 7
2.6 Question 6: Graph Representation - Adjacency List . . . . . . . . . . . 8
2.7 Question 7: Doubly Linked List Implementation . . . . . . . . . . . . 9
2.8 Question 8: MergeSort Algorithm . . . . . . . . . . . . . . . . . . . . . 11
2.9 Question 9: Priority Queue Using Binary Heap . . . . . . . . . . . . . 12
2.10 Question 10: Longest Common Subsequence . . . . . . . . . . . . . . 13

3 Remaining Questions (11–100) 14
3.1 Question 11: Circular Linked List . . . . . . . . . . . . . . . . . . . . . 16

4 Conclusion 17




1

,1 Introduction
This document provides detailed, distinction-level solutions for COS3711 Com-
puter Science Assignment 2 for the 2025 academic year. It includes 100 carefully
crafted questions and answers, focusing on core concepts such as data struc-
tures, algorithms, object-oriented programming, and advanced C++ program-
ming techniques. The solutions are concise, clear, and designed to help stu-
dents achieve high marks while understanding key concepts. Each question is
highlighted in very dark green and accompanied by a detailed explanation and,
where applicable, C++ code snippets to illustrate implementation.


2 Assignment Questions and Solutions
Below are 100 questions and solutions tailored to COS3711 Assignment 2, cov-
ering essential topics in advanced C++ programming and computer science con-
cepts. Each question is highlighted in very dark green to enhance readability
and focus.

2.1 Question 1: Implementing a Binary Search Tree
Solution: A Binary Search Tree (BST) is a data structure where each node has at
most two children, with the left subtree containing nodes with values less than
the parent and the right subtree containing nodes with values greater than the
parent.
#include <iostream>
using namespace std;

struct Node {
int data;
Node* left;
Node* right;
Node(int val) : data(val), left(nullptr), right(nullptr) {}
};

class BST {
private:
Node* root;

Node* insert(Node* node, int data) {
if (!node) return new Node(data);
if (data < node->data)
node->left = insert(node->left, data);
else if (data > node->data)
node->right = insert(node->right, data);
return node;
}

Node* findMin(Node* node) {


2

, while (node->left) node = node->left;
return node;
}

Node* remove(Node* node, int data) {
if (!node) return nullptr;
if (data < node->data)
node->left = remove(node->left, data);
else if (data > node->data)
node->right = remove(node->right, data);
else {
if (!node->left) {
Node* temp = node->right;
delete node;
return temp;
}
if (!node->right) {
Node* temp = node->left;
delete node;
return temp;
}
Node* temp = findMin(node->right);
node->data = temp->data;
node->right = remove(node->right, temp->data);
}
return node;
}

void inorder(Node* node) {
if (node) {
inorder(node->left);
cout << node->data << ”␣”;
inorder(node->right);
}
}

public:
BST() : root(nullptr) {}

void insert(int data) {
root = insert(root, data);
}

void remove(int data) {
root = remove(root, data);
}

void inorder() {
inorder(root);
cout << endl;
}


3
R174,14
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
Kanteez
1,0
(1)

Get to know the seller

Seller avatar
Kanteez Teachme2-tutor
Follow You need to be logged in order to follow users or courses
Sold
6
Member since
9 months
Number of followers
0
Documents
549
Last sold
2 months ago
Kanteez Lab

Kanteez | The S-Tier Mastery Lab Welcome to your academic upgrade. I don’t just sell notes; I provide Elite Mastery Blueprints designed for the student who refuses to settle for "just passing." The Kanteez Philosophy * Cognitive Aesthetics: Most study guides are eyesores that cause mental fatigue. My materials are visually architected to reduce stress and maximize focus. When your study material looks good, you feel good—and when you feel good, you retain information with ease. * Hyper-Efficiency: Your time is your most finite resource. My guides are engineered to cut through the noise, allowing you to master dense, high-stakes exam content with surgical precision. * Elite Outcomes: I specialize in transforming complex topics into streamlined, S-tier resources. My mission is to help you reclaim your time, secure that A+, and step into the elite tier of your field. "Study smarter. Feel better. Dominate the exam." Transform your academic trajectory. Explore the collection below.

Read more Read less
1,0

1 reviews

5
0
4
0
3
0
2
0
1
1

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