Homework 4 Solution

$29.99 $18.99

This assignment consists of 3 questions. Q1: Convert the infix expressions given below to prefix and postfix, then evaluate them. Show your work step by step. A+((B–C*D)/E)+F–G/H !(A&&!((B<C)||(C>D)))||(C<E) Write your solution by latex or word and upload it as a StudentNumber.pdf file. Note: Before evaluation, you must assign values to variables. Q2: Implement a Deque…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

Rate this product

This assignment consists of 3 questions.

Q1:

Convert the infix expressions given below to prefix and postfix, then evaluate them. Show your work step by step.

  1. A+((B–C*D)/E)+F–G/H

  1. !(A&&!((B<C)||(C>D)))||(C<E)

Write your solution by latex or word and upload it as a StudentNumber.pdf file.

Note: Before evaluation, you must assign values to variables.

Q2:

Implement a Deque class which implements Deque interface and can extend AbstractCollection.

Deque is a queue that supports adding or removing items from both ends of the data structure. To implement it, your class should keep two linked list. One for the elements in the deque and the other to keep the nodes removed. You should use a removed node, if any available, when a new node is needed instead of creating a new node. With this type of operation you can save time for constructing new nodes and garbage collection the nodes that are not used anymore.

You are not allowed to use any class in Collection hierarchy as a member. So, you need to define your own Node class to build a linked list. Note that you need to implement all required methods and Iterator class.

Write a Main class to test each method in your class.

Q3: Recursive functions

Define each of the following problem recursively:

Identify the base case (or base cases) that stops the recursion Define the smaller problem (or problems)

Explain how to combine solutions of smaller problems to get the solution of original problem

Write recursive methods for the problems.

  1. Reversing a string. For example, if the input is “this function writes the sentence in reverse”, then the output should be “reverse in sentence the writes function this”.

  1. Determining whether a word is elfish or not. A word is considered elfish if it contains the letters: e, l, and f in it, in any order. For example, whiteleaf, tasteful, unfriendly, and waffles are some elfish words.

  1. Sorting an array of elements using selection sort algorithm.

  1. Evaluating a Prefix expression

  1. Evaluating a Postfix expression

  1. Printing the elements of an array on the screen as in the example below.

Input:

1

2

3

4

5

6

7

8

  • 10 11 12

13 14 15 16

17 18 19 20

Output: 1 2 3 4 8 12 16 20 19 18 17 13 9 5 6 7 11 15 14 10

RESTRICTIONS:

  • Use only specified data types

  • Can be only one main class in each question

  • Don’t use any other third part library

GENERAL RULES:

  • For any question firstly use course news forum in Moodle, and then the contact TA.

  • You can submit assignment one day late and will be evaluated over twenty percent (%40).

TECHNICAL RULES:

  • Use given CSE222-VM to develop and test your Homeworks (your code must be working on CSE222-VM), CSE222-VM download link will be given on Moodle.

  • Implement clean code standards in your code;

  • Classes, methods and variables names must be meaningful and related with the functionality.

  • Your functions and classes must be simple, general, reusable and focus on one topic.

REPORT RULES:

  • Add all javadoc documentations for classes, methods, variables …etc. All explanation must be meaningful and understandable.

  • You should submit your homework code, Javadoc and report to Moodle in a “studentid_hw3.tar.gz” file.

  • Use the given homework format including selected parts from the table below:

Detailed system requirements

Use case diagrams (extra points)

Class diagrams

X

Other diagrams

Problem solutions approach

X

Test cases

X

Running command and results

X

GRADING :

No OOP design:

-100

No interface:

-95

No method overriding:

-95

No error handling:

-50

No inheritance:

-95

No polymorphism:

-95

No javadoc documentation:

-50

No report:

-90

Disobey restrictions:

-100

Cheating

: -200

  • Your solution is evaluated over 100 as your performance.

CONTACT :

  • Teaching Assistant : Başak Karakaş