Questions
Write a class named Palindrome.java and Write a method isPalindrome that takes an IntQueue as a...

Write a class named Palindrome.java and Write a method isPalindrome that takes an IntQueue as a parameter and that returns whether or not the numbers in the queue represent a palindrome (true if they do, false otherwise). A sequence of numbers is considered a palindrome if it is the same in reverse order. For example, suppose a Queue called q stores this sequence of values:

front [3, 8, 17, 9, 17, 8, 3] back

Then the following call:

isPalindrome(q) should return true because this sequence is the same in reverse order. If the list had instead stored these values:

front [3, 8, 17, 9, 4, 17, 8, 3] back

the call on isPalindrome would instead return false because this sequence is not the same in reverse order (the 9 and 4 in the middle don't match).

The empty queue should be considered a palindrome. You may not make any assumptions about how many elements are in the queue and your method must restore the queue so that it stores the same sequence of values after the call as it did before. The method header is specified as follows:

public static boolean isPalindrome(IntQueue q)


public class IntQueue{
Integer[] arr;
int numOfElements=0;
int front=0;
int rear=-1;

public IntQueue(int cap);

public void enqueue(Integer data);
public Integer dequeue();

public boolean isFull();

public boolean isEmpty();
}

methods document:

public class IntStack{
Integer[] arr;
int index=0;

public IntStack(int cap);

public void push(Integer data);
public Integer pop();
public Integer top();
public boolean isFull();

public boolean isEmpty();

}

are the available methods, and we do not have size() or length() which is how i have done these types of problems before.

In: Computer Science

represent -100 in 16-bit binary format and then convert it to Hexadecimal form.

represent -100 in 16-bit binary format and then convert it to Hexadecimal form.

In: Computer Science

What are the steps to be followed in building the Knowledge Management System in hotel.

What are the steps to be followed in building the Knowledge Management System in hotel.

In: Computer Science

Consider a sorting algorithm that combines merge sort and insertion sort algorithm. We still use divide...

Consider a sorting algorithm that combines merge sort and insertion sort algorithm. We still use divide and conquer like merge sort, however when the number of elements in an array is at most k elements (k is a parameter), we stop dividing the elements as the regular merge sort, instead, we call the insertion sort. Assuming we have defined the following two procedures:

insertion-sort(A[p..q]) which sort the subarray A[p..q]

merge(A[p,q,r]) which merges the sorted subarray A[p..r] and A[r+1..q]

  1. Try to write the pseudo code for this algorithm: given array A[p..q] and a parameter k as mentioned above

merge-insert(A[p..q], k)

  1. For an input array of size n, how many times will the insertion be called by the modified merge? In the worst case, what is the total time for these insertion sort?
  1. What is the running time of merge-insert in the worst case? Justify your answer?

In: Computer Science

Must be written in JAVA Code Write a program that takes a whole number input from...

Must be written in JAVA Code

Write a program that takes a whole number input from a user and determines whether it’s prime. If the number is not prime, display its unique prime factors. Remember that a prime number’s factors are only 1 and the prime number itself. Every number that’s not prime has a unique prime factorization. For example, consider the number 54. The prime factors of 54 are 2, 3, 3 and 3. When the values are multiplied together, the result is 54. For the number 54, the prime factors output should be 2 and 3. Use Sets as part of your solution.

In: Computer Science

represent -100 in 16-bit binary format and then convert it to Hexadecimal form.

represent -100 in 16-bit binary format and then convert it to Hexadecimal form.

In: Computer Science

What are some good topics to know about for Software Engineering?

What are some good topics to know about for Software Engineering?

In: Computer Science

PART 3 – Using logical vectors and logical 2D arrays In this part, you will use...

PART 3 – Using logical vectors and logical 2D arrays

In this part, you will use a logical vector to make multiple decisions in parallel concerning values in two arrays. Firstly, generate two random [1x12] arrays using randi. The numbers should be integers between 1 and 5. Let’s call these two arrays a1 and a2. Your task is to generate a third array, a3, which at each index, contains a true/false value that defines whether the values in arrays a1 and a2 are NOT equal (use ~=). Now use the a3 array to obtain those values in a1 and a2 that are equal. You must accomplish all this using the logical vector and no loops.

Finally, create a random 5x5 numeric 2D array with numbers between 1 and 100 using one line of code. Replace all values divisible by 3 in this matrix with the value -1, again, using only one line of code.

In: Computer Science

Convert -99.999 into double precision floating format show all steps and explanations

Convert -99.999 into double precision floating format

show all steps and explanations

In: Computer Science

Convert 103.375 into double precision floating format show all steps and explanations

Convert 103.375 into double precision floating format

show all steps and explanations

In: Computer Science

Convert 103.375 into double precision floating format show all steps and explanations

Convert 103.375 into double precision floating format

show all steps and explanations

In: Computer Science

Convert -99.999 into double precision floating format show all steps and explanations

Convert -99.999 into double precision floating format

show all steps and explanations

In: Computer Science

Search the internet for 5 open source reporting software packages of your choice? Explain why you...

Search the internet for 5 open source reporting software packages of your choice? Explain why you think these software packages are the best for BI/DSS Reporting? Choose one of them and do associated with the reporting software package. Explain how easy it was for you to use the software?

In: Computer Science

Complete the following task in C++. You may use the following libraries cstdlib, string, iostream. 1...

Complete the following task in C++. You may use the following libraries cstdlib, string, iostream.

1 dLL
The class is described according to the simple UML diagram below:


dLL<T>
-head: item<T>*
-tail: item<T>*
-size: int
----------------------------
+dLL()
+~dLL()
+getHead(): item<T>*
+getTail(): item<T>*
+push(newItem:item<T>*):void
+pop():item<T>*
+getItem(i:int):item<T>*
+minNode():T
+getSize():int
+printList():void


The class variables are as follows:


head: The head pointer of the doubly linked list.
tail: The tail pointer of the doubly linked list.
size: The current size of the doubly linked list. This starts at 0 and increases as the list grows in size.


The class methods are as follows:
dLL: The class constructor. It starts by setting the variables to null and 0 respectively.
~dLL: The class destructor. It will deallocate all of the memory in the class.
getHead: This returns the head pointer of the doubly linked list.
getTail: This returns the tail pointer of the doubly linked list.
push: This adds a new item to the doubly linked list, by adding it to the front of the list.
pop: This returns the top item of the linked list. The item is returned and removed from the list.
getItem: This returns the item of the linked list at the index specified by the argument but without removing it from the list. If the index is out of bounds, return null.
minNode: This returns the value of the item that has the lowest value in the linked list.
getSize: This returns the current size of the linked list.
printList: This prints out the entire list in order, from head to tail. Each item's data value is separate by a comma. For example: 3.1,5,26.6,17.3. Remember to add a newline to the end of the output.

2. item


The class is described according to the simple UML diagram below:


item <T>
-data:T
-------------------
+item(t:T)
+~item()
+next: item*
+prev: item*
+getData():T


The class has the following variables:


data: A template variable that stores some piece of information.
next: A pointer of item type to the next item in the linked list.
prev: A pointer of item type to the previous item in the linked list.


The class has the following methods:


item: This constructor receives an argument and instantiates the data variable with it.
~item: This is the destructor for the item class. It prints out "Item Deleted" with no quotation marks and a new line at the end.
getData: This returns the data element stored in the item.

In: Computer Science

Convert -99.999 into double precision floating format show all steps and explanations

Convert -99.999 into double precision floating format

show all steps and explanations

In: Computer Science