×
Log in to StudySoup
Get Full Access to Introduction To Algorithms - 3 Edition - Chapter 15 - Problem 15-4
Join StudySoup for FREE
Get Full Access to Introduction To Algorithms - 3 Edition - Chapter 15 - Problem 15-4

Already have an account? Login here
×
Reset your password

Printing neatly Consider the problem of neatly printing a

Introduction to Algorithms | 3rd Edition | ISBN: 9780262033848 | Authors: Thomas H. Cormen ISBN: 9780262033848 130

Solution for problem 15-4 Chapter 15

Introduction to Algorithms | 3rd Edition

  • Textbook Solutions
  • 2901 Step-by-step solutions solved by professors and subject experts
  • Get 24/7 help from StudySoup virtual teaching assistants
Introduction to Algorithms | 3rd Edition | ISBN: 9780262033848 | Authors: Thomas H. Cormen

Introduction to Algorithms | 3rd Edition

4 5 1 247 Reviews
24
5
Problem 15-4

Printing neatly Consider the problem of neatly printing a paragraph with a monospaced font (all characters having the same width) on a printer. The input text is a sequence of n 406 Chapter 15 Dynamic Programming words of lengths l1; l2;:::;ln, measured in characters. We want to print this paragraph neatly on a number of lines that hold a maximum of M characters each. Our criterion of neatness is as follows. If a given line contains words i through j , where i j , and we leave exactly one space between words, the number of extra space characters at the end of the line is M j C i Pj kDi lk, which must be nonnegative so that the words fit on the line. We wish to minimize the sum, over all lines except the last, of the cubes of the numbers of extra space characters at the ends of lines. Give a dynamic-programming algorithm to print a paragraph of n words neatly on a printer. Analyze the running time and space requirements of your algorithm.

Step-by-Step Solution:
Step 1 of 3

PHYS Notes Week 7 Feb 22­26 Electric Charge ­ Particles have either a positive or negative charge ­ Combining these particles into atoms/molecules result in three possibilities ­ Negatively charged: object contains more negative particles than positive particles ­ Positively charged: object contains more positive particles than negative particles ­ Electrically neutral: object contains equal amounts of positive and negative particles ­ Nature prefers neutral charges ­ The terms "positive" and "negative" don't mean anything; they just refer to the fact that the charges are opposite ­ Electrostatic/electric force: the force that charged particles exert on each other ­ Objects with the same electrical charge repel each other, while objects with opposite electrical charges attract each other ­ Strong electrical charges can induce an opposite charge in a neutrally charged system ­ Grounding it can neutralize a system’s charge ­ Grounding: touching an object to the ground (the earth is so big that it can absorb any extra charge without problem) ­ Unit of electric charge is a coulomb (C) ­ Derived from base unit of ampere, which is a measure of current ­ Current: rate at which charge moves past a given point in a given amount of time ­ Charge is quantized (comes in basic units based on electrons that cannot be divided) ­ Basic unit of charge: electron ­ Historically led to the development of quantum mechanics ­ Charge is conserved (cannot be created or destroyed, only moved around) ­ Charge moving through materials ­ Conductors vs. insulators ­ Conductors allow electrons to move freely (ex. metal) ­ Everything can be a conductor with enough electricity ­ Insulators don't allow electrons to move as freely ­ Semi­conductors are somewhere in between ­ Superconductors allow charge to move without hindrance ­ Coulomb’s law ­ Force exerted by charged particles on each other depends on the size of the charge of the particles as well as their distance from one another ­ Two positive or two negative charges ­­> particles push away from each other; one negative and one positive charge ­­> particles attract each other * Increasing force means opposite charges (attracting particles) ­ Electric fields: electrostatic forces existing around a charged particle ­ Determine what a field looks like by placing a test charge near it and measuring the force applied to the test charge ­ We draw electric field using field lines ­ Field lines closer together shows stronger force ­ Field lines extend away from positive charges and toward negative charges ­ If we create a field, we can direct a particle through it (old TVs) ­ Charged particles have potential energy ­ Electric potential (voltage): potential energy per electrical charge ­ Electric current: flow of electrons in motion (negative to positive) ­ Produced by voltage ­ Inserting battery into loop of conductive material creates a flow ­ Conduction ­ Some materials conduct electricity better due to resistance of the material ­ Resistance inhibits flow ­ Ohm: unit of resistance ­ Ohm's law: as potential increases, current increases, and when resistance increases, current decreases ­ Series Circuits ­ Battery/power supply: creates a difference in potential energy ­ Path from one end of battery to another (wire or other conductive material) ­­> electrical current ­ Electrons pushed through a resistor, which slows the current down/steals kinetic energy from the electrons to power a machine ­ Power multiple machines by adding multiple resistors to circuit around the circuit ­ Each resistor increases the overall resistance of circuit ­ Parallel circuits ­ Put resistors into a circuit next to each other, creating multiple paths for the electron to move through ­ If one of the paths slows down (because electrons have to slow to enter the resistor), the backed­up electrons move through the next parallel resistor ­ Adding resistors decreases the resistance of the circuit, increasing current flow (like adding lanes to a highway) ­ Too fast of a current is an issue because wires can only hold so much electricity ­ Direct current (DC): current that flows in only one direction ­ Usually used in electronics/devices ­ Alternating current (AC): current alternates direction (60 times/s (60 Hz)), which changes, faster than what we can see (20 Hz) ­ Easier to generate and travel over long distances ­ Argument between Tesla (AC) vs. Edison (DC) because AC is dangerous ­ Edison created the electric chair, which used AC ­ Transformers are used to change between AC and DC

Step 2 of 3

Chapter 15, Problem 15-4 is Solved
Step 3 of 3

Textbook: Introduction to Algorithms
Edition: 3
Author: Thomas H. Cormen
ISBN: 9780262033848

The full step-by-step solution to problem: 15-4 from chapter: 15 was answered by , our top Engineering and Tech solution expert on 11/10/17, 05:55PM. Introduction to Algorithms was written by and is associated to the ISBN: 9780262033848. Since the solution to 15-4 from 15 chapter was answered, more than 770 students have viewed the full step-by-step answer. The answer to “Printing neatly Consider the problem of neatly printing a paragraph with a monospaced font (all characters having the same width) on a printer. The input text is a sequence of n 406 Chapter 15 Dynamic Programming words of lengths l1; l2;:::;ln, measured in characters. We want to print this paragraph neatly on a number of lines that hold a maximum of M characters each. Our criterion of neatness is as follows. If a given line contains words i through j , where i j , and we leave exactly one space between words, the number of extra space characters at the end of the line is M j C i Pj kDi lk, which must be nonnegative so that the words fit on the line. We wish to minimize the sum, over all lines except the last, of the cubes of the numbers of extra space characters at the ends of lines. Give a dynamic-programming algorithm to print a paragraph of n words neatly on a printer. Analyze the running time and space requirements of your algorithm.” is broken down into a number of easy to follow steps, and 177 words. This textbook survival guide was created for the textbook: Introduction to Algorithms, edition: 3. This full solution covers the following key subjects: words, characters, neatly, space, paragraph. This expansive textbook survival guide covers 35 chapters, and 151 solutions.

Other solutions

People also purchased

Related chapters

Unlock Textbook Solution

Enter your email below to unlock your verified solution to:

Printing neatly Consider the problem of neatly printing a