It is common for people to name directories as dir1, dir2, and so on. When there are ten or more directories, the operating system displays them in dictionary order, as dir1, dir10, dir11, dir12, dir2, dir3, and so on. That is irritating, and it is easy to fix. Provide a comparator that compares strings that end in digit sequences in a way that makes sense to a human. First compare the part before the digit as strings, and then compare the numeric values of the digits.
Your program should work with the provided test program
DirectorySortDemo.java.
Call the class you write DirectoryComparator.java.
Submit the two files in your submission.
DirectoryComparator.java
DirectorySortDemo.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.collections;
public class DirectorySortDemo
{
public static void main (String [] args)
{
String dirNames ("dir12", "dir5", "dir9", "dirl", "dir4",
"lab10", "1ab2", "lab7", "lab17", "lab8",
"quiz8", "quiz10", "quiz11", "quiz12",
"dirll", "dir8", "dir7", "dir15", "dir3");
ArrayList directories = new
ArrayList<> (Arrays.asList (dirNames));
System.out.println ("Unsorted List:");
System.out.println (directories);
Collections.sort (directories, new DirectoryComparator ());
System.out.println ():
System.out-println ("Sorted List: ");
System.out.-println (directories);

Answers

Answer 1

Answer:

Here the code is given as follows,

Explanation:

It Is Common For People To Name Directories As Dir1, Dir2, And So On. When There Are Ten Or More Directories,

Related Questions

Write a removeDuplicates() method for the LinkedList class we saw in lecture. The method will remove all duplicate elements from the LinkedList by removing the second and subsequent elements. If there is only one copy of an element, it is not removed. The list size should shrink accordingly based on the number of duplicates removed.

Answers

Answer:

removeDuplicates() function:-

//removeDuplicates() function removes duplicate elements form linked list.

   void removeDuplicates() {

     

       //declare 3 ListNode pointers ptr1,ptr2 and duplicate.

       //initially, all points to null.

       ListNode ptr1 = null, ptr2 = null, duplicate = null;

       

       //make ptr1 equals to head.

       ptr1 = head;

        //run while loop till ptr1 points to second last node.

       //pick elements one by one..

       while (ptr1 != null && ptr1.next != null)

       {

               // make ptr2 equals to ptr1.

               //or make ptr2 points to same node as ptr1.

           ptr2 = ptr1;

           //run second while loop to compare all elements with above selected element(ptr1->val).

           while (ptr2.next != null)

           {

              //if element pointed by ptr1 is same as element pointed by ptr2.next.

               //Then, we have found duplicate element.

               //Now , we have to remove this duplicate element.

               if (ptr1.val == ptr2.next.val)

               {

                  //make duplicate pointer points to node where ptr2.next points(duplicate node).

                       duplicate = ptr2.next;

                       //change links to remove duplicate node from linked list.

                       //make ptr2.next points to duplicate.next.

                   ptr2.next = duplicate.next;

               }

               

             //if element pointed by ptr1 is different from element pointed by ptr2.next.

               //then it is not duplicate element.

               //So, move ptr2 = ptr2.next.

               else

               {

                   ptr2 = ptr2.next;

               }

           }

           

           //move ptr1 = ptr1.next, after check duplicate elements for first node.

           //Now, we check duplicacy for second node and so on.

           //so, move ptr1  by one node.

           ptr1 = ptr1.next;

       }

   }

Explanation:

Complete Code:-

//Create Linked List Class.

class LinkedList {

       //Create head pointer.

       static ListNode head;

       //define structure of ListNode.

       //it has int val(data) and pointer to ListNode i.e, next.

   static class ListNode {

       int val;

       ListNode next;

       //constructor to  create and initialize a node.

       ListNode(int d) {

               val = d;

           next = null;

       }

   }

//removeDuplicates() function removes duplicate elements form linked list.

   void removeDuplicates() {

       

       //declare 3 ListNode pointers ptr1,ptr2 and duplicate.

       //initially, all points to null.

       ListNode ptr1 = null, ptr2 = null, duplicate = null;

       

       //make ptr1 equals to head.

       ptr1 = head;

       

       

       //run while loop till ptr1 points to second last node.

       //pick elements one by one..

       while (ptr1 != null && ptr1.next != null)

       {

               // make ptr2 equals to ptr1.

               //or make ptr2 points to same node as ptr1.

           ptr2 = ptr1;

           //run second while loop to compare all elements with above selected element(ptr1->val).

           while (ptr2.next != null)

           {

              //if element pointed by ptr1 is same as element pointed by ptr2.next.

               //Then, we have found duplicate element.

               //Now , we have to remove this duplicate element.

               if (ptr1.val == ptr2.next.val)

               {

                  //make duplicate pointer points to node where ptr2.next points(duplicate node).

                       duplicate = ptr2.next;

                       

                       //change links to remove duplicate node from linked list.

                       //make ptr2.next points to duplicate.next.

                   ptr2.next = duplicate.next;

               }

               

             //if element pointed by ptr1 is different from element pointed by ptr2.next.

               //then it is not duplicate element.

               //So, move ptr2 = ptr2.next.

               else

               {

                   ptr2 = ptr2.next;

               }

           }

           

           //move ptr1 = ptr1.next, after check duplicate elements for first node.

           //Now, we check duplicacy for second node and so on.

           //so, move ptr1  by one node.

           ptr1 = ptr1.next;

       }

   }

   //display() function prints linked list.

   void display(ListNode node)

   {

       //run while loop till last node.

       while (node != null)

       {

               //print node value of current node.

           System.out.print(node.val + " ");

           

           //move node pointer by one node.

           node = node.next;

       }

   }

   public static void main(String[] args) {

       

       //Create object of Linked List class.

       LinkedList list = new LinkedList();

       

       //first we create nodes and connect them to form a linked list.

       //Create Linked List 1-> 2-> 3-> 2-> 4-> 2-> 5-> 2.

       

       //Create a Node having node data = 1 and assign head pointer to it.

       //As head is listNode of static type. so, we call head pointer using class Name instead of object name.

       LinkedList.head = new ListNode(1);

       

       //Create a Node having node data = 2 and assign head.next to it.

       LinkedList.head.next = new ListNode(2);

       LinkedList.head.next.next = new ListNode(3);

       LinkedList.head.next.next.next = new ListNode(2);

       LinkedList.head.next.next.next.next = new ListNode(4);

       LinkedList.head.next.next.next.next.next = new ListNode(2);

       LinkedList.head.next.next.next.next.next.next = new ListNode(5);

       LinkedList.head.next.next.next.next.next.next.next = new ListNode(2);

       //display linked list before Removing duplicates.

       System.out.println("Linked List before removing duplicates : ");

       list.display(head);

       //call removeDuplicates() function to remove duplicates from linked list.

       list.removeDuplicates();

       System.out.println("")

       //display linked list after Removing duplicates.

       System.out.println("Linked List after removing duplicates :  ");

       list.display(head);

   }

}

Output:-

HELP ASAP PLZZZZZ

Question 35(Multiple Choice Worth 5 points)

(03.01 LC)


To write a letter to your grandma using Word Online, which document layout should you choose?


APA Style Paper

General Notes

New Blank Document

Table of Contents

Answers

Answer:

third one

Explanation:

To write a letter to your grandma using Word Online, you should choose the "New Blank Document" layout.

What is Word?

Microsoft Word is a word processing application. It is part of the Microsoft Office productivity software suite, along with Excel, PowerPoint, Access, and Outlook.

To write a letter to your grandmother in Word Online, select the "New Blank Document" layout. This will open a blank page on which you can begin typing your letter.

The "APA Style Paper" layout is intended for academic papers and includes formatting guidelines and section headings that a personal letter may not require.

In Word Online, "General Notes" is not a document layout option.

The "Table of Contents" feature generates a table of contents based on the headings in your document, but it is not a document layout option.

Thus, the answer is "New Blank Document".

For more details regarding Microsoft word, visit:

https://brainly.com/question/26695071

#SPJ2

How many ways are there to arrange the letters in the word ALGORITHMS? Note, the letter arrangement does not have to spell a word in the dictionary, but the new word must contain all the letters and each letter can be used only once.

Answers

there are ten letters in the word, so for the first position we can choose out of 10 option.

no matter wich specific option we choose, we will have 9 letters left for the 2nd letter.

and 8 for the third place.

...

when we will have used up 9 of 10 letters, there will be only one option for the last place.

the number of possible decision-paths is therefore given by this expression:

10*9*8*7*6*5*4*3*2*1

wich is 3,628,800

there are quite a few ways to rearrange 10 letters

The sorting method which commands entries in a going to head predicated on each character without regard to space as well as punctuation, therefore there are 3628800 ways.

The word 'ALGORITHMS' has 10 letters. There is no repeated letter so, the first Letter can hold 10 places if we start taking one letter at a time. The second can then hold nine positions, the third can hold eight, and so on.

So, as [tex]\bold{ 10\times 9 \times 8.... \times 3 \times 2 \times 1 = 362,8800}[/tex] ways, we have such a total number of ways.

Learn more:

brainly.com/question/17276660

Write a class Example() such that it has a method that gives the difference between the size of strings when the '-' (subtraction) symbol is used between the two objects of the class. Additionally, implement a method that returns True if object 1 is greater than object 2 and False otherwise when the (>) (greater than) symbol is used. For example: obj1

Answers

Answer:

Here the code is given as follows,

Explanation:

class Example:

   def _init_(self, val):

       self.val = val

   def _gt_(self, other):

       return self.val > other.val

   def _sub_(self,other):

       return abs(len(self.val) - len(other.val))

def main():

   obj1 = Example('this is a string')

   obj2 = Example('this is another one')

   print(obj1 > obj2)

   print(obj1 - obj2)

main()

Output:-

Alice sends a message to Bob in a manner such that Bob is the only person who can tell what the real message is. Which security concept is this an example of

Answers

Answer:

confidentiality

Explanation:

Alice sends a message to Bob in a manner such that Bob is the only person who can tell what the real message is. Which security concept is this an example of

This type of security concept is an example of confidentiality. Thus, option B is correct.

What is security?

Security is the capacity to withstand possible damage from other individuals by placing restrictions on their right to act freely. The term security is the absence of threat or a sense of safety.

Any uncovered danger or weakness in any technology that could be exploited by criminals to compromise equipment or knowledge is a security threat.

It has to do with Alice’s ability to decide on their own how if, and why people exploit individual data if it is being sent to bob. To ensure human rights, welfare, and consciousness, solitude must be protected. People are able to independently create their own personalities.

Therefore, option B is the correct option.

Learn more about security, here:

https://brainly.com/question/15278726

#SPJ2

The question is incomplete, the complete question is:

a. message integrity

b. confidentiality

c. availability

d. non-repudiation

e. authentication

State two ways of preventing virus attack on a computer.​

Answers

Answer:

updating the computer and having an anti virus on your computer

Ms. Lawson, a primary school teacher, told her students that a photograph of the president is in the public domain. What does she mean by this?

Answers

Answer:

He belongs to the nation

Using the concepts of public and private domains, it means that the photograph of the president can be used by anyone without asking for permission.

---------------

Public and private domains:

If an image is of private domain, there is the need to ask the owner for the right to use the image.If it is of public domain, there is no need, as is the case for the president photo in this question.

A similar question is given at https://brainly.com/question/12202794

SQLite is a database that comes with Android. Which statements is/are correct?
The content of an SQLite database is stored in XML formatted files because XML is the only file format supported by Android OS.
A SQLite database is just another name for a Content Provider. There is no difference as the SQLite implementation implements the Content Provider interface.
If an app creates an SQLite database and stores data in it, then all of the data in that particular database will be stored in one, single file.
A database query to an SQLite database usually returns a set of answers
To access individual entries, SQLite provides a so-called Cursor to enumerate all entries in the set.
This is yet another example of the Iterator pattern.

Answers

Answer:

1. Wrong as per my knowledge, SQLite may be an electronic database software that stores data in relations(tables).

2. Wrong. Content provider interface controls the flow of knowledge from your android application to an external data storage location. Data storage is often in any database or maybe it'll be possible to store the info in an SQLite database also.

3.Right. SQLite uses one file to store data. It also creates a rollback file to backup the stored data/logs the transactions.

4. Wrong. The queries are almost like a traditional electronic database system, the queries are going to be answered as per the conditions given and should return a group of answers or one answer depending upon the info and sort of query used.

5. Right. A cursor helps to point to one entry within the database table. this may be very helpful in manipulating the present row of the query easily.

Other Questions
if p-1/p = 4 Find (p+1/p) In a clinic, a doctor charges Rs 1200 for every 15 minutes. If he attends to the clinic 2 hours per day for seven days, how much will he earn during a week? Suppose that demand is unitary elastic at all points. When price is increased from a point on this demand curve, then total revenue will_____________. How many O2 molecules react with 47 CH4 molecules according to the preceding equation CH4 + O2 CO2 + H2O Question 4 (True/False Worth 4 points)(0701)True or False?is a solution to the inequality 12+2 < 12TrueO False what is the differences in responsibilities between councils and offices that make up the Executive Office of the President? Tim and Al are bricklayers. Tim can construct an outdoor grill in 5 days. If Al helps Tim, they can build it in only 3 days. How longwould it take Al to build the grill alone? Write your answer as an integer, simplified fraction, or mixed number.It would take Aldays to build the grill alone. Why do you think during the evolutionary process there was a correlation between brain size increasing while cecum size decreased in the omnivores?How does insect respiration differ from that of vertebrate respiration? How do they manage to respire? i really need someones help on this one asap. LUVFINANCE, Inc. is estimating its WACC. The firm could sell, at par, $100 preferred stock that pays a 10 percent annual dividend and incurs 4.72% flotation costs. What is the cost of new preferred stock financing? What is the first step when applying properties of operations to divide 73.85 by 4.1?Multiply the divisor and dividend by 10.O Multiply the divisor and dividend by 100. Divide the divisor and dividend by 10. Divide the divisor and dividend by 100. According to the prompt, how will you support your analysis? is the movement of employees among positions at the same organizational level rather than through progression and promotuion A plane flies from Los Angeles west to Paradise Isle and returns. During both flights there is a steady upper air wind from the west at 80 mph. If the trip west to Paradise Isle took 17 hours and the return trip to Los Angeles took 13 hours, what was the plane's average airspeed? Which of the following is a subordinate clause?A. Where I forgot my notebookB. Just between you and meC. Last but not leastD. Off to the races The DEF partnership reported net income of $130,000 for the year ended December 31, 20X8. According to the partnership agreement, partnership profits and losses are to be distributed as follows in the following order: D E FSalaries $25,000 $20,000 $15,000Bonus on net income 10% ----- -----Remainder 60% 30% 10%Required:How should partnership net income for 2008 be allocated to D, E, and F? The triangles are similar. If QR = 9, QP = 6, and TU = 19, find TS. Round to the nearest tenth.A) 16B) 12.7C) 2.8D) 28.5 The narrative structure of monster does what One purpose of using a visual aid is to clarify complex ideas that are difficult toexplain verbally.TrueFalse At what distance x from the center of the coil, on the axis of the coil, is the magnetic field half its value at the center?