Write a recursive a Java code that checks if a number is
Palindrome. A
palindrome number is a number that reads the same from beginning to
end and
from end to beginning, in other words, a palindrome number remains
the same
when its digits are reversed. For example, 13431 is a palindrome
number. 2332
is another one. (Note: Your algorithm should define and work with
an integer
number)
The functionality of your code should be commented to explain what
you do in
each part of the code.
You need to run your code for the following test cases and show the
result:
1) 0 (output:
yes)
2) 1234554321 (output: yes)
3) 123454321 (output: yes)
4) 1221 (output: yes)
5) 1234 (output:
no)
6) 7676 (output: no)
7) -121 (output: yes)
8) -456 (output: no)
What is the time complexity of your algorithm? Cleary justify
your
answer.
In: Computer Science
Please show screenshots from the command prompt! Thank
you!
In: Computer Science
Script 3:
Please show screenshots from the command prompt! Thank you!
In: Computer Science
Java Problem:
Array lists and linked lists are both implementations of lists. Give an example of a situation where an array list would be the better choice and one where a linked list would. Explain the reasons in each case. Provide example.
In: Computer Science
I am currently working on this problem. It says it is wrong, and I was wondering if someone could correct my code to where its ouput is as followed.
Expected Output:
6↵ 5↵ 4↵ 3↵ 2↵ 1
Actual Output:
9↵ 8↵ 7↵ 6↵ 5↵ 4↵ 3↵ 2↵ 1↵ 0↵
9.10: Reverse Array
Write a function that accepts an int array and the array’s size as
arguments. The function should create a copy of the array, except
that the element values should be reversed in the copy. The
function should return a pointer to the new array. Demonstrate the
function by using it in a main program that reads an integer
N (that is not more than 50) from
standard input and then reads
N integers from a file named
data into an array. The program then
passes the array to the your reverse array function, and prints the
values of the new reversed array on standard output, one value per
line. You may assume that the file data
has at least N values.
Prompts And Output Labels. There are no prompts for the integer and no labels for the reversed array that is printed out.
Input Validation. If the integer read in from standard input exceeds 50 or is less than 0 the program terminates silently.
I used this code:
#include<iostream>
#include<fstream>
using namespace std;
int *reverse(const int *, int);
int main()
{
int N;
N=10;
/*
cin >> N;
if(N > 50 || N < 0)
exit(0);
*/
// int *arr1 = new int[N], index;
int *arr1=new int[N];
int index;
for(int i=0;i<N;i++)arr1[i]=i;
/*
fstream datafile;
datafile.open("data.txt", ios::in | ios::out);
for(index = 0; index < N; index++)
{
datafile >> arr1[index];
}
*/
int *temp;
temp = reverse(arr1,N);
for(index = 0; index < N; index++)cout << temp[index]
<< endl;
system("PAUSE");
}
int *reverse(const int *arr1, int N)
{
int index = N-1;
int *arr2;
arr2 = new int[N];
for(int count = 0; count < N; count++)
{
arr2[count] = arr1[index];
index--;
}
return arr2;
}
In: Computer Science
1) Describe what is PCI DSS and what are the specific requirements for Applications?
In: Computer Science
C# Arrays & methods
I'm having trouble implementing the GetIntArrayFromUser method in the following problem:
Create a method AverageIntArray that takes an array of integers
and calculates and returns the average of all values in the array
as a double Write a program that uses GetIntArrayFromUser method to
get an array of 7 numbers, then calls the AverageIntArray method to
get the average then prints all values in the array that are
greater than the average.
Sample run:
Enter next whole number: 3
Enter next whole number: 8
Enter next whole number: 4
Enter next whole number: 12
Enter next whole number: 13
Enter next whole number: 6
Enter next whole number: 9
Average: 7.85714285714286
8
12
13
9
here is GetIntArrayFromUser:
public void GetIntArrayFromUser()
{
Console.WriteLine("Enter number of list items");
int size = Convert.ToInt32(Console.ReadLine());
int[] arr = new int[size];
for (int i = 0; i < size; i++)
{
Console.WriteLine("Enter next whole number");
arr[i] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("Items in the list: ");
foreach (int item in arr)
{
Console.WriteLine(item);
}
}
In: Computer Science
SQL Assignment
Discuss why and when cursors could be used.
In: Computer Science
;the task is to print out the result no matter how many digits
; it should work on Emu8086
;the code should be in assembly language
; add comments to your code
org 100h
.data
F db 0
num1 db 0
num2 db 0
op db 0
result db 0
msg db 0dh,0ah,"Error"
.code
mov ax,@data
mov ds,ax
LL1:
call get1
cmp ax,0
je print
cmp F,0
je LL1
LL2:
call get2
cmp ax,0
je print
cmp F,1
je LL2
Solve:
cmp op,'+'
je addition
mov bl, num1
sub bl,num2
mov result,bl
jmp printresult
addition:
mov bl, num1
add bl,num2
mov result,bl
printresult:
;Task: add code to print result
jmp done
print:
mov cx,7
mov si,0
screen:
mov dl,msg[si]
mov ah,2
int 21h
inc si
loop screen
done:
ret
get1 proc
mov ah,1
int 21h
cmp al,'+'
je L4
cmp al,'-'
je L5
sub al,30h
cmp al,0
jb L2
cmp al,9
ja L2
mov cx,10
mov bh,0
L3:
add bh,num1
loop L3
add bh,al
mov num1,bh
ret
L4:
mov op,'+'
mov F,1
ret
L5:
mov op,'-'
mov F,1
ret
L2:
mov ax,0
ret
endp
get2 proc
mov ah,1
int 21h
cmp al,'='
je L41
sub al,30h
cmp al,0
jb L21
cmp al,9
ja L21
mov cx,10
mov bh,0
L31:
add bh,num2
loop L31
add bh,al
mov num2,bh
ret
L41:
mov F,2
ret
L21:
mov ax,0
ret
endpIn: Computer Science
Solve the following Double Linked List sort: use int. array = {8, 3, 12, 9, 6, 2} and provide visualization development to the solution.
In: Computer Science
Compare and Contrast PDLC (Program Development Life Cycle) and SDLC (System Development Life Cycle) as well as Application Programmers and Web Programmers and also Application and Website. Please answer. Thank you
In: Computer Science
Write a boolean function named isMember that takes two
arguments: an array of type
char and a value. It should return true if the value is found in
the array, or false if the
value is not found in the array.
PLEASE WRITE FULL PROGRAM IN C++ AND USE RECURSION AND DO NOT USE LOOPS
In: Computer Science
IN C++
Rather than clutter up the source code with blocks of essentially the same calculations or blocks of code controlled by IF then…else logic, we can move these blocks of code into one location that can be called from anywhere and anytime during the application’s execution, the “function”.
Functions can be passed “arguments”, one or more data values and return zero or one value to the calling routine Functions can call other separate functions or even themselves recursively.
If the divisor, n2, is zero, display a message, “Cannot divide by zero” in the function, default n2 to 1, return the dividend and display it in the main.
Example Output:
1 of 2 - Enter First Number: 12.34
2 of 2 - Enter Second Number: 8.4
1 - Add (12.34 + 8.4)
2 - Subtract (12.34 - 8.4)
3 - Multiplication (12.34 X 8.4)
4 - Divide (12.34 / 8.4)
5 – ALL
6 – Change Values
7 - Quit
Enter an Option (1 to 7): 3
12.34 X 8.4 = 103.656
Hit Any Key to continue...
1 - Add (2.4 + -3.4)
2 - Subtract (2.4 - -3.4)
3 - Multiplication (2.4 X -3.4)
4 - Divide (2.4 / -3.4)
5 - ALL
6 - Quit
Enter an Option (1 to 7): 5
2.4 + -3.4 = -1
2.4 - -3.4 = 5.8
-3.4 - 2.4 = -5.8
2.4 X -3.4 = -8.16
2.4 / -3.4 = -0.705882
Hit Any Key to continue...
In: Computer Science
Abstraction is a key part of object-oriented programming and the concepts apply particularly well to classes. How would the same concepts apply to data structures and how we tend to define and think of ADTs?
In: Computer Science
develop the Binary search with swap count: Use sorted data from insertion sort (part A) Permutations, Insertion Sort – implement algorithms Permutations (Johnson Trotter): {1, 2, 3, 4, 5}; Insertion Sort: {45, 24, 16, 92, 71, 69, 28} develop count of # data “insertions” and develop # of key compares against the following: 16, 77, 24, 92, 44
In: Computer Science