in java we need to order a list , if we create a program in java what are the possible ways of telling your program how to move the numbers in the list to make it sorted, where each way provides the required result.
list the name of sorting with short explanation
In: Computer Science
I want c++ /c program to build a double linked list and find with a function the middle element and its position and the linked list must be inserted by the user aand note You should handle the both cases of whether the size of the list even or odd
In: Computer Science
IN SCHEME
Write a function subtract which takes a list of numbers as a parameter and returns a list of the differences. So, a list containing the second minus the first, third minus the second, etc.
(subtract '(3 4 10 14 5))
'(1 6 4 -9)
In: Computer Science
Do it in python please
This lesson's Group Activities are:
We're going to take the Group Activity from last week and tweak it. Instead of storing the random numbers in a list, we're going to store them in a file. Write a program using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a file. It should then display the following data to back to the user:
Helpful hint: don't forget about input validation loops and try/catch exceptional handling. Both are very useful when used in conjunction with functions.
In: Computer Science
#Write a function called wish_list. wish_list should have
#four parameters, in this order:
#
# - a list of strings, representing a list of items on a
# wish list
# - a string, representing a particular item
# - a float, representing the cost of this item
# - a float, representing your budget
#
#If the item is on the list and you can afford it (cost is
#less than or equal to budget), return the string,
#"You should buy a [item name]!", replacing [item name]
#with the string.
#
#If the item is on the list but you can't afford it,
#return the string, "You should save up for a [item name]!",
#replacing [item name] with the string.
#
#If the item is not on the list, you should return the
#string "You probably don't want to buy a [item name].",
#replacing [item name] with the string.
#
#HINT: You do not need a loop to solve this. You can use
#one, but you don't need one.
In: Computer Science
You are asked to delete the last occurrence of an item from a linked list. So, for instance:
Input: 2 -> 3 -> 2 -> 4
Delete last occurrence of 2, result: 2 -> 3 -> 4
Implement the following method to do the deletion. You may NOT use or implement helper methods - all your code must be implemented inside the given method. You may NOT use recursion.
public class Node {
public int data;
public Node next;
}
// Deletes LAST occurrence of given item from a linked
list,
// given a front pointer to the first node in the list.
// Returns pointer to first node of the updated linked list.
// Input list could be empty.
// Throws NoSuchElementException if item is not in the linked
// list.
public static Node deleteLastOccurrence(Node front, int
item)
throws NoSuchElementException {
// COMPLETE THIS METHOD
}
In: Computer Science
1. Write a python program to create a list of integers using random function. Use map function to process the list on the expression: 3x2+4x+5 and store the mapped elements in another list. Now use filter to do sum of all the elements in another list.
2. Write a function that takes n as input and creates a list of n lists such that ith list contains first 10 multiples of i.
3. Write a function that takes a number as input parameter and returns the corresponding text in word. For example, on input 458, the function should return ‘Four Five Eight’. Use dictionary for mapping digits to their string representation.
4. Write a program to create two sets of integer type using random function. Perform following operations on these two sets:
a) Union
b) Intersection
c) Difference
d) Symmetric difference
In: Computer Science
Through Python, a dictionary or list is often used to store a sequential collection of elements. Suppose, for instance, that you need to read 50 numbers, compute their average, and then compare each number with the average to determine whether it is below or above the average. In order to do this (without the use of list), you would first declare 50 variables to store the 50 numbers. This means you would have to create 50 variables and repeatedly write almost the identical code 50 times. Writing a program this way is impractical. To overcome this issue, you can make use of a list to store all the 50 numbers and access them through a single list variable.
For your initial post, describe the difference between dictionary and list in Python and explain when each would be used. Provide an example of how each dictionary and list would be implemented within Python. 250 WORDS
In: Computer Science
Please attach the output screenshots, narrative descriptions, or paste the Python codes when requested.
Task 2
Please define a function that extracts the even numbers in a given list. For example, given a list x = [2,3,5,6,7], the function will return a sublist [2,6] because 2 and 6 are even numbers in the list x.
The input of this function should be a list, and the output of the function should be a list as well (the sublist).
You can try the inline for loop with conditions to make the solution super simple.
Task 3
Use inline for loop to extract the common elements in two lists. For example, if x = [1,2,3], and y = [2,3,4], the result should be [2,3].
Hint: to check if a value exists in a list, you can use the “in” command. For example: we define two variables
a = 2 in [1,2,3]
b = 4 in [1,2,3].
After executing the codes, a will be a “True”, and b will be a “False”.
In: Computer Science
Book
SerialNum : String -
Name: String –
PublishYear: int -
+ Book()
Book(String, String, String, int , int)+
+ setName(String) : void
+ setSerialNum(String) : void
+ setAuthor(String) : void
+ setEdition(int) : void
+ setYear(int) : void
+ getName():String
+ getAuthor():String
+ getYear(): int
+ getSerialNum(): String
+ getEdition():int
+ setAvailable() : void
+ setUnavailable(): void
checkAvailability(): boolean
-----------------------------------------------------------------------------------
Library
Name : String
Address: String
Static NUMBEROFBOOKS: int
BooksAtLibrray : ArrayList
LibraryIssues: TreeMap
Library()
Library(String, String)
addBook(Book): void
removeBook(Book) : Boolean
searchBookByName(Book) : Boolean
searchBookBySerialNumber(Book) : Boolean
checkBookAvailablity(Book): Boolean
createLibraryIssue(LibrrayIssue):Boolean
addLibraryIssue(LibraryIssue)
removeLibrrayIssue(LibrrayIssue):Boolean
searchLibrrayIssueByStuent(Student): List
searchLibraryIssuebyID(String IssueID):LibrrayIssue
searchLibraryIssueByBook(Book): LibraryIssue
--------------------------------------------------------------------------------------------------------------
Student
id : String
Name: String
Age : int
Student()
Student(String, String, int)
setName (String):void
SetAge(int):void
setId(String):void
getID():String
getName():String
getAge():int
---------------------------------------------------------------------------------------------------
LibraryIsuue
IssueID : String
borrower : Student
borrowedBook : Book
LibraryIssue()
LibraryIssue(String, Student , Book)
setIssueId(String):void
setBorrower(Student):void
setBorrowedBook(Book):void
getIssueID():String
getBorrowed():Student
getBorrowedBook():Book
----------------------------------------------------------------------------------------------------------
Librray
Main()
-----------------------------------------------------------------------------------------------------------------------------------------
Use the attached UML diagrams to build up your project classes
Make sure to put view for your project by Entering true data
You will need to add 5 books and 5 students and at least 3 LibraryIssues
LibraryIssues keeps track of the borrowed book
The librray uses all classes as mentioned in the UML diagram
You will need to check if book is available before borrowing it.
searchLibrrayIssueByStuent(Student): List
This method returns all book if borrowed by single student, as a student could borrow more than one book
Static NUMBEROFBOOKS: int
Each time you add a book the static variable is increased and Each time a book is removed so the static variable is decreased.
createLibraryIssue(LibraryIssue) : boolean
changed the Boolean variable status in book element to false and return false if book is not available
removeLibrrayIssue(LibraryIssue):Boolean
changed the Boolean variable status in book element to true and return false if book is available
Note
LibrrayIssue and Book in the class Library should be List or map
Do not use array as the size is not fixed
In: Computer Science