Algorithm 1, known as Hoare-partition, is a partitioning algorithm based on the decremental design and designed by Hoare. The algorithm takes an array A, a starting index p, and an ending index r as input and partitions the array into two parts based on a pivot element x.
In the first line of the algorithm, the pivot element x is selected as A[p]. Then, two indices, i and j, are initialized to p-1 and r+1, respectively. The algorithm enters a loop where j is decremented until an element A[j] less than x is found. Similarly, i is incremented until an element A[i] greater than x is found. Once i and j stop moving, the algorithm checks if i is less than j. If true, it means elements A[i] and A[j] are in the wrong partitions, so they are swapped. This process continues until i and j cross each other.
The algorithm effectively partitions the array into two parts: elements less than or equal to x on the left side and elements greater than x on the right side. The position where i and j cross each other marks the boundary between the two partitions. Overall, Hoare-partition algorithm follows a decremental design where it starts with two pointers moving inward from opposite ends of the array until they meet, swapping elements as necessary to create the desired partition.
Learn more about algorithm here: https://brainly.com/question/21364358
#SPJ11
a computer program consists of two blocks written independently by two different pro- grammers. the first block has an error with probability 0.2. the second block has an error with probability 0.3. if the program returns an error, what is the probability that there is an error in both blocks?
Using the probability of independent events, it is found that there is a 0.06 = 6% probability that there is an error in both blocks.
What is probability?Mathematical representations of the likelihood of an event occurring or of a proposition being true are dealt with in the area of probability.The probability of an event is a number between 0 and 1, where 1 denotes certainty and 0 normally denotes impossibility.Gonna determine how likely something is to occur, use probability. Many things are hard to predict with 100% certainty.We can only forecast how likely an event is to occur using it, or how likely it is to occur.P (E) = Number of positive results and The formula for determining an event's probability uses the total number of possible outcomes. Probability is hence the possibility that a random occurrence will take place.If two occasions, A and B, are separated, the probability of both happening is the expansion of the probability of each ensuing, that is:
P(A ∩B)= P(A)P(B)
In this problem, the possibilities are:
Event A: Error on the first block, with 0.2 probability, hence
P(A)=0.2
Event B: Error on the second block, with 0.3 probability, hence
P(B)=0.3
The probability that there is an error in both blocks is:
P(A ∩B)= P(A)P(B)= 0.2(0.3)=0.06
0.06 = 6% probability that there is an error in both blocks.
To learn more about probability, refer to:
https://brainly.com/question/24756209
#SPJ4
Hinata needs to upload a copy of her drivers license to a website as proof of age which two devices can she use to help her create a computer file of her card
Answer:
Scanner SmartphoneExplanation:
For Hinata to upload a copy of her driver's license she needs to scan the license. This would convert it to a soft copy/ computer copy that can then be uploaded on the site.
One device she can use is the very common Scanner. There are multiple variants but they usually consist of a scanning plane/ glass that the license can be placed on and scanned. A digital copy will then be created.
A second device is simply her smartphone. There are many apps that can be used to scan documents via the phone's cameras so she just has to use one of them and she can easily scan the license thereby converting it to a computer file.
Answer:
Scanner and web cam
Explanation:
Help I will give brainliest! Critical thinking questions!
\(question - \)
\(the \: picture \: is \: completely\: dark\)\(it \: will \: be \: very \: help \: full \: if \: you \\ post\: the \: question \: again \: \)Helppp me eeeeee eee
Answer:
a. taking risks
Explanation:
i hope this helps
Answer:
Most likely taking risks...but that is my opinion
Explanation:
hope I helped :]
[Files, for loops, exceptions; 20pt] Using a for loop, write a function called countWord(). It takes 2 parameters: The name of a text file (e.g. gettysburg.txt that is included with this test) and a word to be searched within that file. Your code should return the number of times the given word appears in the file. Capitalization should not matter. Make certain to handle file exceptions gracefully.
def countWord(name, word):
try:
f = open(name, "r")
lst = ([])
w = ""
for x in f.readlines():
w += x.lower()
lst = w.split()
f.close()
return lst.count(word)
except FileNotFoundError:
print("Please create a file or use the name of an existing text file.")
print("Your word appears", countWord("gettysburg.txt", "random"), "time(s)")
The text file I used for testing looks like:
random words
random words
I'm putting random words in here
random
this is random
RaNdOm
I didn't really know what exceptions your professor is looking for so I just used the file not found one. Best of luck.
Write 2-4 short & energetic sentences to interest the reader! Mention your role, experience & most importantly - your biggest achievements, best qualities and skills about data entry.
Searching for an information section genius? Look no further! With north of 5 years of involvement and a 99.9% precision rate, I'm the ideal possibility for your information passage needs. My scrupulousness, speed, and proficiency will guarantee that your information is precisely and productively entered, like clockwork. We should cooperate to make your information passage calm!
How can you make sure to save all annotations from a slide show?
When you exit the slide show, select Keep the Annotations.
O Before beginning the slide show, select Save All Annotations.
During the slide show, right-click and select Save Annotations.
O All annotations are automatically saved as a copy of the presentation.
Answer:
when you exit the slide show, select keep annotations
Explanation:
To save all annotations from a slide show, make sure that When you exit the slide show, select Keep the Annotations.
What is annotation?This is known to be a kind of a note that is said to be added through comment or explanation.
It is often used by writers. Note that the right thing to do is to To save all annotations from a slide show, make sure that When you exit the slide show, select Keep the Annotations.
Learn more about Annotations from
https://brainly.com/question/16177292
create a stored procedure called updateproductprice and test it. (4 points) the updateproductprice sproc should take 2 input parameters, productid and price create a stored procedure that can be used to update the salesprice of a product. make sure the stored procedure also adds a row to the productpricehistory table to maintain price history.
To create the "updateproductprice" stored procedure, which updates the sales price of a product and maintains price history, follow these steps:
How to create the "updateproductprice" stored procedure?1. Begin by creating the stored procedure using the CREATE PROCEDURE statement in your database management system. Define the input parameters "productid" and "price" to capture the product ID and the new sales price.
2. Inside the stored procedure, use an UPDATE statement to modify the sales price of the product in the product table. Set the price column to the value passed in the "price" parameter, for the product with the corresponding "productid".
3. After updating the sales price, use an INSERT statement to add a new row to the productpricehistory table. Include the "productid", "price", and the current timestamp to record the price change and maintain price history. This table should have columns such as productid, price, and timestamp.
4. Finally, end the stored procedure.
Learn more about: updateproductprice
brainly.com/question/30032641
#SPJ11
How does Google work, why does it work that way?
Answer:
Google uses automated programs called spiders or crawlers, just like most search engines, to help generate its search results. Google has a large index of keywords that help determine search results. ... Google uses a trademarked algorithm called PageRank, which assigns each Web page a relevancy score.
Answer: Google uses automated programs called spiders or crawlers, just like most search engines, to help generate its search results. Google has a large index of keywords that help determine search results. ... Google uses a trademarked algorithm called PageRank, which assigns each Web page a relevancy score.
Explanation: Google's algorithm does the work for you by searching out Web pages that contain the keywords you used to search, then assigning a rank to each page based several factors, including how many times the keywords appear on the page. ... Google references this index when a user enters a search query.
Hope this helps^^
You are required to write a program which will convert a date range consisting of two
dates formatted as DD-MM-YYYY into a more readable format. The friendly format should
use the actual month names instead of numbers (eg. February instead of 02) and ordinal
dates instead of cardinal (eg. 3rd instead of 03). For example 12-11-2020 to 12-11-2022
would read: 12th of November 2020 to 12th of November 2022.
Do not display information that is redundant or that could be easily inferred by the
user: if the date range ends in less than a year from when it begins, then it is not
necessary to display the ending year.
Also, if the date range begins in the current year (i.e. it is currently the year 2022) and
ends within one year, then it is not necesary to display the year at the beginning of the
friendly range. If the range ends in the same month that it begins, then do not display
the ending year or month.
Rules:
1. Your program should be able to handle errors such as incomplete data ranges, date
ranges in incorrect order, invalid dates (eg. 13 for month value), or empty values
2. Dates must be readable as how they were entered
The program which will convert a date range consisting of two dates formatted as DD-MM-YYYY into a more readable format will be:
from datetime import datetime
def convert_date_range(start_date, end_date):
start_date = datetime.strptime(start_date, '%d-%m-%Y')
end_date = datetime.strptime(end_date, '%d-%m-%Y')
return f"{start_date.strftime('%B %d, %Y')} - {end_date.strftime('%B %d, %Y')}"
# Example usage:
start_date = '01-04-2022'
end_date = '30-04-2022'
print(convert_date_range(start_date, end_date)) # Output: April 01, 2022 - April 30, 2022
How to explain the programIn this code example, we first import the datetime module, which provides useful functions for working with dates and times in Python. Then, we define a function called convert_date_range that takes in two arguments, start_date and end_date, which represent the start and end dates of a range.
Inside the function, we use the datetime.strptime() method to parse the input dates into datetime objects, using the %d-%m-%Y format string to specify the expected date format. Then, we use the strftime() method to format the datetime objects into a more readable string format, using the %B %d, %Y format string to produce a string like "April 01, 2022".
Learn more about program on:
https://brainly.com/question/1538272
#SPJ1
find the film_title of all films which feature both ralph cruz and will wilson.
The SQL query to find the film_title of all films which feature both Ralph Cruz and Will Wilson can be written as:
SELECT DISTINCT f.film_title
FROM films f
INNER JOIN film_cast fc1 ON f.film_id = fc1.film_id AND fc1.actor_name = 'Ralph Cruz'
INNER JOIN film_cast fc2 ON f.film_id = fc2.film_id AND fc2.actor_name = 'Will Wilson';
This query joins the films table with the film_cast table twice, once for each actor. The INNER JOIN ensures that only the films which feature both actors are returned. The DISTINCT keyword ensures that each film title is only returned once. In summary, the above SQL query will return the film titles of all films which feature both Ralph Cruz and Will Wilson by joining the films table with the film_cast table twice, once for each actor, and returning only the distinct film titles.
Learn more about SQL here:
https://brainly.com/question/31837731
#SPJ11
6 A command performs:
a) a specific block
b) none of the blocks
c) a chore that I was asked to do
d) only blocks within a loop
Answer:D
Explanation:
Congratulationsill You have just been hired on as a Network Specialist by MW5G Network Consulting. The police have asked for the wireless support staff for Melille's Coffee Cale to meet with them; you are sent on behalf of MWSG as their representative. Apparently three customers of Melville's coffee Gafe have had their identity stolen and it seems they were all at the colfee shop during the first week of November of this year, and they were all using their laptops. The police suspect someone at the cafe was somehow snooping on the customer's computers. They hwe a suspect from the video survellance camera, but they want to know how the bad gay did it. 1. You take a look at the router at Metvite's Coffee Cafe: it's using Channel 1, has an SS1D of MELVILIFSCAFE, and the WEP security key is 17 characters long ["AhoyYetandlubbers") Do you Mee any issues here? does x −1 have ony gseriol charotius. [wrak passue 2. What do you think the method of attack was? - mion in the ridelle. 3. Explain how the bad guy did it. - Attaetur just bijak the wite. 4. The police are confused - why wouldn't the custemers have been aware of the attack? - Pecause we disn't trel mon in the middle a thaw no delay. 5. What steps will you take to try to ensure the problem stops?
From the information provided, it appears that there are several issues with the router at Melville's Coffee Cafe. Firstly, it is using channel 1 which is a common channel and can cause interference with other devices in the area.
Additionally, the SSID (MELVILIFSCAFE) is easily guessable and the WEP security key is only 17 characters long which is not considered secure. This makes it relatively easy for an attacker to gain access to the network.
What is Network Specialist?Based on the information provided, it is likely that the method of attack was a "man-in-the-middle" attack. This type of attack involves intercepting and manipulating communication between two parties without either party being aware of the attack.
The bad guy likely used tools such as a wireless sniffer to gain access to the network and intercept the communication between the customers' laptops and the router. They may have also used techniques such as ARP spoofing to redirect the traffic to a device under their control, allowing them to intercept and read the data.
The customers may not have been aware of the attack because the man-in-the-middle attack likely did not cause any noticeable changes to their experience, such as delays or connectivity issues. Additionally, the attacker may have been able to hide their actions by encrypting the intercepted data.
To try to ensure that the problem stops, I would take several steps:
Change the SSID and WEP key to something more secureConfigure the router to use a different channel to avoid interferenceImplement a more secure encryption method such as WPA2Monitor the network for suspicious activity and take appropriate actionLearn more about Network Specialist from
https://brainly.com/question/29352369
#SPJ1
What file format is best to give a printer when working with Adobe InDesign?
GIF
TIFF
HTML
IDML
Answer:
TIFF
Explanation:
GIFs are animated image files, and printers can't print animations
TIFFs are basically image files
HTML is a coding file, you were to print it, it would print the HTML text of the image
IDML is an XML representation of an InDesign document or components, if you were to print it, its outcome would be basically the same as printing an HTML file.
Multifactor authentication requires you to have a combination of:_______
The correct answer is Multifactor authentication requires you to have a combination of two or more of the following factors: something you know, something you have, or something you are.
"Something you know" refers to a secret or personal information, such as a password, PIN, or answers to security questions. This factor confirms that the user has knowledge of specific information that only they should know "Something you have" refers to a physical object that is in the user's possession, such as a smart card, token, or mobile device. This factor confirms that the user has access to a specific object that only they should have. Something you are" refers to a biometric factor, such as a fingerprint, facial recognition, or voice recognition. This factor confirms the user's unique physical characteristics that are difficult to forge or replicate. By combining two or more of these factors, multifactor authentication provides an extra layer of security beyond just a username and password. It helps to protect against unauthorized access, identity theft, and other security threats.
To learn more about Multifactor authentication click on the link below:
brainly.com/question/14437331
#SPJ4
Disadvantages and advantages of utp and stp cables
The disadvantages and advantages of utp are:
UTP cables are known to be the most used form of networking cables on the global market and are seen as the fastest copper-based medium that is known to be available. They are said to be less expensive than those of STP cables.They are easily dispensable.What is STP advantages and disadvantages?The Shield of STP cables are known to be one that need to be properly grounded so that it can function as an antenna and carry unwanted signals.
Note that it is seen as a More expensive kind of cable than the UTP and they are also seen to be very Difficult to keep and maintain. They are said to have thicker diameter and not very flexible.
Hence, The disadvantages and advantages of utp are:
UTP cables are known to be the most used form of networking cables on the global market and are seen as the fastest copper-based medium that is known to be available. They are said to be less expensive than those of STP cables.They are easily dispensable.Learn more about cables from
https://brainly.com/question/16889976
#SPJ1
Takes a 3-letter String parameter. Returns true if the second and
third characters are “ix”
Python and using function
Answer:
def ix(s):
return s[1:3]=="ix"
Explanation:
a given program is parallelized to run in an 8-core multicore processor. if 1/8th of the program remains serial while 7/8ths is parallelized, what is the speedup of the program?
When a system's resources are upgraded, Amdahl's Law predicts the theoretical speed in latency of a process at a fixed workload.
It is used to forecast the theoretical speedup in parallel computing when many processors are used.
Amdahl's Law speed for an unlimited number of processes is calculated as follows:
Maximum Speedup, S = \(\frac{1}{sequential part}\) = \(\frac{1}{1/8}\)= 0.08
Limit of Speedup on 8-core processor, S = 8/(1+ (8-1)*12.5 )= 0.09
What is a Multi-core Processor?
A single processor chip with multiple processors on it that are housed in a single container is known as a multi-core processor.
A processor, often known as a "core," is a circuit that executes commands or computations.
A multicore processor can run programs and do calculations more quickly than a single processor chip because it contains many processing units.
The majority of today's computers, smartphones, and tablets employ multicore processors, which enable them to operate more quickly than they would if they used a single-core processor chip.
To know more about Multi-core Processor, visit: https://brainly.com/question/14442448
#SPJ4
what was the name of the earliest version of the internet?
Answer:
The ARPANET (Advanced Research Projects Agency Network)
List two rules of a data protection art.
Answer:
1 the data must be processed fairly, lawfully and transparently
2 the data must be processed only for specific, explicit and legitimate purposes and shall not be further processed in any manner incompatible with that purpose or those purposes
3 the data must be adequate, relevant, and not excessive in relation to the purpose or purposes for which they are held
Which sentence contains an error?
(Not about technology but about journalism. Answer fast please. Thank you)
Answer:
The correct answer is A
Explanation:
All the rest of them make sense but letter A so your correct answer is A
Good Luck
Write an input command using the variable company_name.
Answer:
company_name = input("What if your company name?");
print("I hope " + company_name + "becomes successful!");
Explanation:
The input of the user becomes a variable which is then stored in order to print it out as a message.
The spreadsheet below shows how much money each store raised for charity during the months of January, February, and March. A1: Blank. B1: Store 1. C1: Store 2. D1: Store 3. A2: January. B2: 170 dollars. C2: 100 dollars. D2: 150 dollars. A 3: February. B3: 235 dollars. B4: 80 dollars. D3: 240 dollars. A4: March. B4: 300 dollars. C4: 75 dollars. D4: 450 dollars. Using this information, answer the following questions. To obtain the total amount raised by Store 1, which range of cells would you use?
PLEASE HURRY I HAVE TO FINISH BY 12:00
Answer:
B2:B4
Explanation:
Answer:B2:B4 ,sum ,using the sum and average functions on the range of cells
Explanation:
trust i took the test
a server profile enables a firewall to locate which server type
A server profile is a configuration or set of specifications that defines the characteristics and behavior of a server. It typically includes details such as the server's operating system, hardware specifications, network settings, installed software, and security configurations.
While a server profile itself does not enable a firewall to locate a specific server type, it can provide information that can help in identifying the server's characteristics. For example, if a server profile specifies that the server is running a specific operating system, has certain open ports, or is hosting specific services, a firewall can use this information to determine the server type or category.
Firewalls are network security devices that monitor and control incoming and outgoing network traffic based on predefined rules. They analyze network packets and make decisions on whether to allow or block traffic based on various factors, including source IP address, destination IP address, port numbers, and protocol.
To identify the server type, firewalls can use various techniques such as port scanning, protocol analysis, and deep packet inspection. These techniques involve examining the characteristics of network packets to determine the services or applications running on a particular server.
It's important to note that server profiling and firewall analysis are separate processes, but they can complement each other in identifying and securing network resources.
Learn more about Firewalls :brainly.com/question/30456241
#SPJ4
you are sharing your computer screen to collaborate on a document. which view should vou use to minimize the ribbon and give vour document the most screen space?
Using the Full-Screen view in your document editor when sharing your screen during collaboration can provide the largest possible viewing area for the document and minimize distractions, allowing for more focused and efficient collaboration.
Explain the reasons why Full-Screen view should be used while sharing screen.When collaborating on a document and sharing your computer screen, it's important to optimize your view to maximize the available screen space. One way to achieve this is by using the Full-Screen view in your document editor. This view removes all interface elements, including the ribbon and toolbars, providing the largest possible viewing area for the document.
The full-Screen view is particularly useful when presenting or sharing a document with others, as it minimizes distractions and allows the viewer to focus solely on the content. In addition, some document editors may have additional features available in Full-Screen mode, such as immersive reading options, simplified formatting tools, or customizable page layouts.
To access Full-Screen view, you can usually find an icon in the toolbar or go to the "View" menu and select "Full Screen" or "Presentation Mode". By using this view, you can ensure that your document is presented in the most visually optimized way possible, making it easier for you and your collaborators to work together more efficiently.
To learn more about Full-Screen, visit:
https://brainly.com/question/11322089
#SPJ1
you receive an email from your bank informing you that their privacy policy has been updated and asking you to review it on their website. what is the safest way to visit your bank's website?
Here is the safest way that you can follow when visiting your bank's website:
Ensure the bank's website uses an HTTPS web address. Change your password regularly. Use multi-factor authentication. Don't open your bank account on public computers. Use a secured wifi connection.The safest way when visit a bank's website is to access your bank's official online or mobile banking app using a secured Wi-Fi connection. Banking with unverified or untrusted apps or over unsecured Wi-Fi connections could leave you vulnerable to cyberattacks.
You can learn more about the cyberattacks at https://brainly.com/question/27726629
#SPJ4
PSEUDOCODE PRACTICE!!! NEED HELP IMMEDIATELY!!! FIRST ANSWER GETS BRAINLYEST!!!
Answer:
a-nothing b-3 c-9 d-1
Explanation:
research on the 5th generation of computers stating the advantages and disavantage how such computers were designed,examples of such computers etc
The 5th generation of computers, also known as the artificial intelligence (AI) era, was designed to incorporate advanced technologies such as machine learning, natural language processing, and expert systems. These computers were designed to have the ability to learn, reason, and make decisions based on complex data sets.
Advantages of 5th generation computers include:
Improved efficiencyIncreased intelligence: More natural interactionWhat are the 5th generation of computers?The Disadvantages of 5th generation computers include:
High cost: Due to their advanced technologies, 5th generation computers can be quite expensive.Complexity: These computers are often more complex to use and maintain than previous generations of computers, which can be a disadvantage for some users.Therefore, the Examples of 5th generation computers include:
IBM WatsonGo/ogle AssistantAmazon AlexaLearn more about computers from
https://brainly.com/question/21474169
#SPJ1
When configuring the authentication methods for a remote access server, you should select the option Allow remote systems to connect without authentication
Based on the computer technology setup, it is False that when configuring the authentication methods for a remote access server, you should select the option Allow remote systems to connect without authentication.
What are Remote Access Systems?Remote Access Systems is a type of system that can be used to regulate and control access to a computer or network.
Remote Access System or Control can be operated anywhere and anytime.
However, in this case, the correct option to pick is "Allow DirectAccess Only." This option will allow a user to connect without authentication.
Deploying Remote Access from the Remote Access Management consoleThere are three methods upon which one can deploy remote access; these methods include the following:
DirectAccess and VPNDirectAccess onlyVPN onlyHence, in this case, it is concluded that the correct answer is False.
Learn more about Remote Access Systems here: https://brainly.com/question/24339774
Hey, I am in need of urgent help! My teacher is REALLY bad at his job (no exaggeration) and if I dont get a 100 on this lab, I will fail the class. Please help me, thank you!!!
This link contains the instructions and classes needed for the lab:
https://www.dropbox.com/sh/469usrw1vctot52/AAARAgfqC63k3OPksAkvdRsGa?dl=0
Please put the code in the Circular List Class, the rest is already done, thanks!
Answer:
public class CircularList
{
private ListNode head; // front of the LinkedList
private ListNode tail; // last node of the LinkedList
private int size; // size of the LinkedList
// constructs a new CircularList
public CircularList()
{
head = tail = null;
size = 0;
}
// returns the size of the array
public int size()
{
return size;
}
// returns whether the list is empty
public boolean isEmpty()
{
return (size == 0);
}
// returns the value of the first node
public Integer first()
{
if (head != null) {
return head.getValue();
}
return -1;
}
// returns the value of the last node
public Integer last()
{
if (tail != null) {
return tail.getValue();
}
return -1;
}
// adds a node to the front of the list
public void addFirst(Integer value)
{
head = new ListNode(value, head);
if (tail == null) {
tail = head;
}
size++;
}
// adds a node to the end of the list
public void addLast(Integer value)
{
ListNode newTail = new ListNode(value, null);
if (tail != null) {
tail.setNext(newTail);
tail = newTail;
} else {
head = tail = newTail;
}
size++;
}
// adds a node at the position pos
public void addAtPos(int pos, Integer value)
{
if (pos == 0) { // Add at the start
addFirst(value);
return;
}
if (pos <= 0 || pos > size) { // Ignore attempts to add beyond the ends
return;
}
if (pos == size) { // Special case, tail has to be adjusted
addLast(value);
return;
}
// size and pos are guaranteed both non-zero
ListNode ptr = head; // ptr is the node before the new one
for(int i=0; i<pos-1; i++) {
ptr = ptr.getNext();
}
ListNode newNode = new ListNode(value, ptr.getNext());
ptr.setNext(newNode);
size++;
}
// removes the first node and returns the value of the removed node or -1 if the list is empty
public Integer removeFirst()
{
Integer retVal = -1;
if (head != null) {
retVal = head.getValue();
head = head.getNext();
size--;
}
if (size == 0) {
head = tail = null;
}
return retVal;
}
// removes the node at position pos and returns the value of the removed node or -1 if pos is not a valid position
public Integer removeNode(int pos)
{
Integer retVal = -1;
if (head == null || pos < 0 || pos >= size) {
return retVal;
}
if (pos == 0) {
return removeFirst();
}
ListNode ptr = head; // ptr is the node before the deleted
for(int i=0; i<pos-1; i++) {
ptr = ptr.getNext();
}
retVal = ptr.getNext().getValue();
if (pos == size-1) { // Is it the last element?
tail = ptr;
tail.setNext(null);
} else {
ptr.setNext(ptr.getNext().getNext());
}
size--;
return retVal;
}
// finds and returns the position of find, or -1 if not found
public int findNode(Integer find)
{
ListNode ptr = head;
for(int pos=0; pos<size; pos++) {
if (ptr.getValue() == find) {
return pos;
}
ptr = ptr.getNext();
}
return -1;
}
// rotates the list by placing the first element at the end
public void rotate()
{
addLast(removeFirst());
}
// returns the list of values in the LinkedList
public String toString()
{
String output = "";
ListNode iter = head;
while(iter != null) {
output += String.format("%d ", iter.getValue());
iter = iter.getNext();
}
return output;
}
}
Explanation:
Enjoy. Linked list are always more complex than you expect. It is a good exercise to try once, then start using libraries. Life is too short to debug linked lists!