Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Case: . 1. Using Huffman code, we can compress the bits used for saving the characters in a file: Total bits used for saving the

Case:

. 1. Using Huffman code, we can compress the bits used for saving the characters in a file:

image text in transcribed

Total bits used for saving the character in table 1 is 264 bits using standard ASCII 8 bits for 1 character.

Using Huffman code encoding in Table 2, the total bits used is 126 bits.

The problem:

Input: list of characters such as table 1

Output: total bits using Huffman code encoding (table 2)

Task: Design an algorithm in pseudocode/code to print the total bits using Huffman code encoding and write down the Algorithm analysis. The complexity of the algorithm must be in O(n) and proof it!

PS: you dont need to sort the input since the input is already sorted!

2. In a square maze, we can have multiple steps from s to reach e with one place that can only be visited once. Example:

image text in transcribed

The problem:

Input: an integer followed by the maze.

Output: total number of unique steps. (no need to print the unique steps)

Task: Design an algorithm in pseudocode/code to print the total number of unique steps using a backtracking algorithm.

3. From the following list of bus rapid transit system (one way):

image text in transcribed

The problem:

Task: Design an algorithm to read the bus rapid transit system routes list and print the number of tickets we need to purchase if we want to visit all places minimal twice. The complexity of the algorithm must be O(V+E). V is the number of places. E-> is the number of transits.

PS: Use Tarjans or Kosarajus strongly connected component algorithm.

4. In a string, we can have repeated pattern. Example:

image text in transcribed

The problem:

Input: a string in a line.

Output: Print the pattern and the repeated count if there is a repeated pattern, Print "none" otherwise.

Task: Design an algorithm in pseudocode/code to for the problem and write down the Algorithm analysis. The complexity of the algorithm must be in O(n). PS: You use the algorithm for string matching taught in class. The repeated pattern is valid only from the first character.

Table. 1. Characters count. Character Frequency E 1 F 1 Table 2. Character bit using Huffman code Character Bits Frequency Total Bits Space 3 4 12 A 3 4 12 H 1 S 3 4 M 1 12 D 4 2 8 1 R T G 4 1 2 8 Y 1 4 3 1 12 D 4 L 2 8 2 2 N 4 3 12 G L 4 2 O 2 8 4 0 Y 2 4 1 I 3 E 5 1 5 F N 3 5 1 5 4 H 5 1 5 Space A S M 5 1 5 4 4 R 5 1 5 T 5 1 5 Total: 126 Input 3 Output 4 These are the unique steps: s.. # e# N These are the unique steps: 4 .S.. .#.# #e. # Name Vacation Work 1 Work 2 Work 3 Route A->B->C->D E->B->F->G->H B->N->E H->D->N Output none Input abc abaa aaaa abab abcabc ababacababac ababacababacababac none (a) 4 (ab) 2 (abc) 2 (ab) 2 (ababac) 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions