1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Slav-nsk [51]
4 years ago
6

How to do assignment 5 on edhesive please help

Computers and Technology
1 answer:
Shalnov [3]4 years ago
8 0

Answer:

//To enter a string, and enter a pivot string, and then print in required sequence, the string from pivot string to last as first string, and printed before the left portion of string.

import java.util.Scanner;

public class Main {

 public static void main(String args[]) {

   Scanner s1 = new Scanner(System.in);

   System.out.println("Enter Main String:");

   String f1 = s1.nextLine();

   System.out.println("Enter pivot(string):");

   String piv = s1.nextLine();

   int start1 = f1.indexOf(piv);

   int end1 = piv.length()+start1;

   if (start1 == -1){

     System.out.println("Error: Sub string(Pivot) cannot be found.");

     return;

   }

   String first1 = f1.substring(0,start1-1);

   String second1 = f1.substring(end1);

   if (f1.charAt(start1-1)==' '){

     System.out.println(second1 + " " + piv + " " + first1);

     return;

   }

   System.out.println(second1 + piv + first1);

   

 }

}

Explanation:

Please check the answer section

You might be interested in
My friend Leo wants to have an emergency plan for his final exams on University of Southern Algorithmville. He has N subjects to
leonid [27]

Answer:

Greedy is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate benefit. Greedy algorithms are used for optimization problems. An optimization problem can be solved using Greedy if the problem has the following property: At every step, we can make a choice that looks best at the moment, and we get the optimal solution of the complete problem.

If a Greedy Algorithm can solve a problem, then it generally becomes the best method to solve that problem as the Greedy algorithms are in general more efficient than other techniques like Dynamic Programming. But Greedy algorithms cannot always be applied. For example, the Fractional Knapsack problem (See this) can be solved using Greedy, but 0-1 Knapsack cannot be solved using Greedy.

The following are some standard algorithms that are Greedy algorithms.

1) Kruskal’s Minimum Spanning Tree (MST): In Kruskal’s algorithm, we create an MST by picking edges one by one. The Greedy Choice is to pick the smallest weight edge that doesn’t cause a cycle in the MST constructed so far.

2) Prim’s Minimum Spanning Tree: In Prim’s algorithm also, we create an MST by picking edges one by one. We maintain two sets: a set of the vertices already included in MST and the set of the vertices not yet included. The Greedy Choice is to pick the smallest weight edge that connects the two sets.

3) Dijkstra’s Shortest Path: Dijkstra’s algorithm is very similar to Prim’s algorithm. The shortest-path tree is built up, edge by edge. We maintain two sets: a set of the vertices already included in the tree and the set of the vertices not yet included. The Greedy Choice is to pick the edge that connects the two sets and is on the smallest weight path from source to the set that contains not yet included vertices.

4) Huffman Coding: Huffman Coding is a loss-less compression technique. It assigns variable-length bit codes to different characters. The Greedy Choice is to assign the least bit length code to the most frequent character. The greedy algorithms are sometimes also used to get an approximation for Hard optimization problems. For example, the Traveling Salesman Problem is an NP-Hard problem. A Greedy choice for this problem is to pick the nearest unvisited city from the current city at every step. These solutions don’t always produce the best optimal solution but can be used to get an approximately optimal solution.

6 0
3 years ago
Which option will Joan use to get a glimpse of how her presentation will look when she presents it to her audience? Joan will us
Murrr4er [49]

Since Joan wants to see what her presentation would look like in the eyes of her audience, it might be best for her to use the Slideshow view that is available at the bottom right side of her desktop view.

This option is a full-screen form of her Normal view in Microsoft PowerPoint. The Slideshow view is represented by the projector screen symbol next to the zoom in and out bar.

7 0
3 years ago
Read 2 more answers
Which describes the buying formula theory of selling ?
Tcecarenko [31]
buying a describing word because it giving money to the person who owns the place and it's very kind thank you
3 0
3 years ago
What are the positive things the internet does for society
Norma-Jean [14]

Answer:

1speed, 2security,3easy online collaboration

Explanation:

1you can share and transfer files very first

2-different users access levels and password can be created to restrict an outhorised person

6 0
3 years ago
When looking to ensure your website is easily accessible by mobile users, what should you focus on doing first
antoniya [11.8K]

Answer:

There are may steps in this procedure but there few steps that do first to access your mobile with your website.

Explanation:

When we are looking in our website and easily accessed by the mobile users, It is easy for them.

There are certain steps that should do first.

  • First step is that you have to redesign the website color scheme
  • To optimize your website
  • To create the mobile app
  • Now to shorten the content in website.

6 0
4 years ago
Other questions:
  • Give an example of an if/else statment and a case statment that are equivalent. Your example should contain at least three choic
    5·1 answer
  • A security system uses sensors at every door and window which will set off an alarm if any one of them is opened. There is also
    9·1 answer
  • What country threatens Denmark at the beginning of Hamlet as evidenced in Marcellus’s question, "Why this same strict and most o
    13·1 answer
  • If you have two pennies, the probability of both coming up heads when flipped
    13·2 answers
  • Which model emphasizes the risk analysis phase of development
    12·1 answer
  • An image can be copied from the Internet or another location and pasted into Paint.
    13·1 answer
  • Compare and contrast the uses of NetWitness Investigator and Wireshark used in the lab. Why would a network administrator use Wi
    8·1 answer
  • How to test someone elese internet speed from a distance
    15·1 answer
  • What is e banking effects
    7·1 answer
  • CISC vs RISC processors might be used, and come up with environments where one processor would outperform the other.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!