Solving Algorithms

 

1. (Total: 8 pts) A grad student comes up with the following algorithm to sort an array A[1..n] that
works by first sorting the first 2/3rds of the array, then sorting the last 2/3rds of the (resulting) array,
and finally sorting the first 2/3rds of the new array.
1: function G-SORT(A, n) . takes as input an array of n numbers, A[1..n]
2: G-sort-recurse(A, 1, n)
3: end function
4: function G-SORT-RECURSE(A, `, u)
5: if u − ` ≤ 0 then
6: return . 1 or fewer elements already sorted
7: else if u − ` = 1 then . 2 elements
8: if A[u] < A[`] then . swap values
9: temp ← A[u]
10: A[u] ← A[`]
11: A[`] ← temp
12: end if
13: else . 3 or more elements
14: size ← u − ` + 1
15: twothirds ← d(2 ∗ size)/3e
16: G-sort-recurse(A, `, ` + twothirds − 1)
17: G-sort-recurse(A, u − twothirds + 1, u)
18: G-sort-recurse(A, `, ` + twothirds − 1)
19: end if
20: end function
1
a (4 pts). First, prove that the algorithm correctly sorts the numbers in the array (in increasing order).
After showing that it correctly sorts 1 and 2 element intervals, you may make the (incorrect) assumption that the number of elements being passed to G-sort-recurse is always a multiple of 3 to simplify
the notation (and drop the floors/ceilings).
Solution.
2
b (1 pts). Next, Derive a recurrence for the algorithm’s running time (or number of comparisons
made).
Solution.
3
c (3 pts). Finally, obtain a good asymptotic upper bound (big-O) for your recurrence.
Solution.
4
2. (Total: 3 pts) Least counterexample: Give a proof by contradiction using the least counterexample
method that:
Xn
i=0
i =
n(n + 1)
2
for all n ≥ 0.
Solution.
5
3. (Total: 8 pts) Define the sequence Tn = (n − 1) + n−1
n2 ·
Pn−1
k=1 Tk. Prove, by induction, for all n ≥ 1,
that Tn ≤ 2n.
Solution.
6
4. (Total: 14 pts) Let S(n) be defined, for n ≥ 2, as S(n) = 2S(d
n
2
e) + nlog2
(n). For n = 1, the value
is S(n) = 1.
(a) (4 pts) Can you apply Master Theorem on S(n)? If no, precisely state why not. If yes, apply the
theorem and derive the bound.
Solution.
7
(b) (10 pts) Now use a method, besides Master Theorem, to prove that S(n) ∈ O(n(log2n)
2
).
Solution.
8
5. (5 points) You are presented with two sorting algorithms. You have to select one of them. The
documentation provided states that both of these algorithms perform Ω(n
3
) comparisons in the worst
case. You want to build a fast program and therefore want to optimise speed. Does it matter which
algorithm you select? How would you make the decision?
Solution.
9
6. (Total: 12 pts)You are interested in building a coffeeshop and charging station beside a freeway running between two cities. Let n be the number of interchanges between the cities, and number them
consecutively so that interchange 0 is at the first city, 1 is the next interchange, and so on, with n − 1
being the interchange at the other city. We say each interchange i is adjacent to interchanges i−1 and
i + 1 (only).
Each interchange i has a cost c(i) to construct a coffee shop/charging station. Call an interchange
i a local minimum if (and only if) the cost of building there is less than the costs of building at the
adjacent interchanges, i.e. both c(i) < c(i + 1) and c(i) < c(i − 1). You want to ensure that you
build at a local minimum so that no one can build a coffeeshop/charging station more cheaply at an
adjacent interchange.
You can assume that:
• n ≥ 3, so there is at least one interchange between the cities.
• The costs at the cities c(0) and c(n−1) are both known to be the same large number (say 100n).
• The other costs are all different and are all strictly less than c(0) (and thus also less than c(n−1)).
The difficulty is that the c(i) values are not known ahead of time (except for c(0) and c(n − 1)) and it
is expensive to determine the cost of building at any interchange.
The goal is to create a divide and conquer algorithm that finds any interchange k that is a local
minimum while examining relatively few of the c(i) values. Although there may be many local
minimums, your algorithm need only find one of them.
(a) (2 points) First, prove that a local minimum exists.
Solution.
10
(b) (5 points) Clearly describe a divide and conquer algorithm for the problem.
Two pages have been left blank for this question. If you do not need both the page, please leave
the second page blank.
Solution.
11
12
(c) (3 points) Prove that your algorithm is correct.
Solution.
13
(d) (2 points) Analyze the (worst case) number of interchange costs (i.e. c(i) values) examined by
your algorithm as a function of n.
Solution.
14

 

 

 

 

 

 

Sample Solution

 

 

Aram Khachaturian (1903-1978) was a Soviet-Armenian writer and conductor who, alongside Shostakovich and Prokofiev, was considered as one of the incomparable Titans of Soviet music. He wrote in basically all types including ensembles, ballet performances, chamber works, and concerti. All around portrayed by music pundit Edward Greenfield:

Khachaturian’s music quite outshone other Soviet peers in making a pointedly recognizable style, something which his successors have discovered difficult to emu late. In critical thoughts he remains here and there as the model of the Soviet author, equipped [through his ballet productions, film scores, accidental music and utilitarian work/walk songs] to correspondence with the most stretched out crowd.

This exposition will concentrate on Aram Khachaturian’s violin concerto, written in 1940 during his principle compositional period from 1936-1948. It will likewise inspect his kinship with performers, for example, David Oistrakh, the conspicuous Soviet musician who the concerto is devoted to. Furthermore the paper will quickly investigate his relations to the socialist party; subsequently how this affected his arrangements and his profession.

Aram Khachaturian was conceived on June 6, 1903 into a white collar class family in the city of Tiflis, presently Tbilisi, current Republic of Georgia. Tiflis was at the time a multicultural focus in the Caucasus, uniting Armenian, Georgian, and Azerbaijani individuals. It was this social condition that turned into the melodic premise of every one of his works, inarguably adding to his unusual compositional style. In an article titled “My Idea of the Folk Element in Music” (1952), Khachaturian composed:

I experienced childhood in an environment wealthy in society music: well known celebrations, customs, happy and tragic occasions in the life of the individuals constantly joined by music, the striking tunes of Armen ian, Georgian and Azerbaijani melodies and moves performed by people versifiers [ashugs] and artists – such were the impressions that turned out to be profoundly engraved on my memory, that my melodic reasoning. They formed my melodic cognizance and establish at the frameworks of my aesthetic character.

At eighteen years of age, Khachaturian moved to Moscow and enlisted at the Gnessin Musical Institute in 1922. His piece instructors included Mikhail Gnessin, Reinhold Glière, and later at the Moscow Conservatory, the striking Nikolay Myaskovsky and Sergey Vasilenko. It was after his graduation from the Moscow Conservatory in 1936 that Khachaturian’s melodic yield significantly expanded. His most outstanding works, including his First Symphony, his piano, violin, and cello concertos, the artful dance Gayane, and the Masquerade Suite were altogether composed during this multi year organize from 1936-1948. Truth be told, his set of three of concertos in no time became significant staples of Soviet old style music.

In 1939, Khachaturian made a multi month excursion to the Soviet Republic of Armenia. This visit demonstrated to be of most extreme significance, as he was welcomed with the chance of seeing his local country, its kin, melodic customs and way of life. “Khachaturyan’s long remain in Armenia presented to him an abundance of striking impressions. His fellowship with Armenia’s national culture and melodic practice demonstrated for him, as he put it himself, ‘a subsequent conservatoire’: The melodic impressions which had so affected the brain of Khachaturyan the kid and the adolescent introduced themselves in another light to Khachaturyan the develop craftsman”. It was on this outing he gave his spirit to the expressive dance, Happiness, which debuted in Yerevan at the Spendiarov Opera and Ballet theater in September of 1939. “Work on Happiness and investment in the celebration of Armenian workmanship had brought Khachaturyan still nearer to Armenia’s otherworldly life and culture.” The expressive dance was later modified to Gayane in the spring of 1941, when Khachaturyan left to the city of Perm close by the migrated Leningrad Kirov Opera and Ballet Theater. Gayane was a moment sensation, and it utilized conventional Armenian and Caucasian people tunes and moves, for example, the Georgian move Lezginka. One of the numbers, the Saber Dance, is still performed globally as a remain solitary instrumental work and regularly used in films.

Khachaturian’s life be that as it may, was not constantly a smooth course. In February of 1948, the Communist Party’s Central Committee, including head Andrei Zhdanov, reproved the music of Khachaturian, Shostakovich and Prokofiev – pronouncing it as formalist and against Soviet. Every one of the three writers had their collection precluded from execution lobbies and establishments, and had to openly apologize. This tragically affected Khachaturian, who was an eager socialist, having formally joined the Communist Party in 1943. He reviewed, “I was squashed, crushed. I genuinely thought to be evolving callings”. Khachaturian had joined the Union of Soviet Composers as Deputy Chairman in 1937, and after two years he turned into the Deputy President of the Moscow branch. The reprimand by Zhdanov was increasingly a reprobation of the advancement of the Union of Soviet Composers instead of Khachaturian’s music itself. The upbraiding was reestablished after the conciliatory sentiment, in spite of the fact that his melodic style remained the equivalent. Truth be told, From then on, Khachaturian turned his enthusiasm to leading and educating at the Gnessin Institute and the Moscow Conservatory. He turned into the secretary of the Composer’s Union in 1957, holding the situation until his passing. Khachaturian composed his second expressive dance Spartacus, which debuted in 1956 and successfully demonstrated to be his last globally famous work. He passed on the first of May, 1978, and was covered at the Komitas Pantheon in Yerevan nearby other Armenian learned people and craftsmen.

Aram Khachaturian composed his violin concerto in an exceptionally brief timeframe. He spent the mid year of 1940 in the Ruza Composer’s Home, a stretch of cabins and stops along the Moscow River where authors would go to rest, work, and be loaded up with innovativeness. The work was done in around over two months – an aftereffect of his profoundly dynamic and creative personality. Khachaturian claims “I worked with no exertion, here and there my considerations and minds outraced the hand that was covering the staffs with notes. The topics came to me in such wealth that I made some hard memories of placing them in some kind of request”. The debut of the concerto occurred in Moscow on November 16, 1940, performed by its dedicatee, David Oistrakh, who Khachaturian kept close contact with while composing the work. The concerto was energetically gotten, and only one year after its debut, won the most elevated masterful honor of the Soviet Union, the Stalin Prize, which was later renamed as the State Prize. Khachaturian’s objective recorded as a hard copy the work was “to make a virtuoso piece utilizing the symphonic guideline of improvement but justifiable to the overall population”. This demonstrated to be a triumph, as after hearing the opening development of the concerto, the audience is in a split second snared on the driving rhythms and the well off significant songs that overwhelm the whole work. The concerto is normal for customary Armenian tunes, yet it doesn’t straightforwardly cite any society tunes. Rather it utilizes rhythms suggestive of society music just as melodic sections joining interims of a second – especially an expanded second. “This dissonant interim frequenting me originates from the trio of the society instruments comprising of the tar, kemancha, and tambourine. I relish such sonorities and to my ear[s] they are as normal as any consonance”. Despite the fact that Khachaturian himself never conceded any additional melodic relationship with his violin concerto, as I would like to think, the three developments can be deciphered as an ordered history of the Armenian individuals, especially the decimation of 1915. Be that as it may, during the USSR, the massacre was to a great extent disregarded by the Soviet government, so it would not have been fitting for Khachaturian to openly express this.

The principal development depicts the long periods of antiquated Armenia, when the realm was always fighting with encompassing domains, for example, the Persians, Romans, and the Arabs. Two differentiating topics are displayed and created all through the whole development. The symphony enters with a ground-breaking presentation, and the violin comes in soon after with a musical entry (see figure 1.a) trailed by a quick move like figure. Tuning in to the opening musical entry, it is hard not to envision a steed’s jog – which is a free symbolism of going to fight.

Figure 1.a: cadenced opening of the violin solo delineating a steed’s dash

From the primary minute the musician has the chance to show his/her virtuosity, as the principal development is loaded up with quick and complex entries. The ensemble part also isn’t in the ‘foundation’ as customary backup, yet rather fills in as a strong establishment all through the development, creating rich harmonies and flying rhythms. The principal topic compares the subsequent topic, which comes in nearly as an amazement to the audience. It is an exceptionally lovely and expressive song that is normal for an Armenian people tune, particularly taking note of the bounteous utilization of the interim of a second. This stunning sentimental subject as I would like to think is an adoration scene of two darlings amidst a disorderly fight between two realms. The utilization of portamentos in the violin part and its emotional discussion with the string area of the ensemble gives trace of a scene commanded by sentiment. All through the development we see the advancement of these two topics, as the development shifts back and forth among expressive and musical entries. It closes triumphantly, as though the “fight is won,” after a virtuosic cadenza drives legitimately to the reiteration of the principle topic, and the development crescendoes in dramatization and power right until the last harmonies.

This question has been answered.

Get Answer
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
👋 Hi, Welcome to Compliant Papers.