Hurricane Dorian is moving towards the Bahamas and is expected to bring torrential rain and potentially dangerous conditions to the islands.
The storm may also hit the US and residents of coastal Florida and the Carolinas have been urged to monitor its progress.
A tropical storm warning has been issued on southern Florida’s east coast, while a tropical storm watch was also issued between Deerfield Beach down to Golden Beach.
The National Hurricane Center is forecasting a slow-moving storm that could linger over Florida for 24 hours before moving on and dissipating.
High pressure over the mainland could force the storm to stall, says Haiyan Jiang, a tropical cyclone researcher at Florida International University. “We’re always watching that high pressure.”
“If the storm slows down after landfall, that could dump a lot of rain. That will make things even worse,” says Jayantha Obeysekera, the director of the Sea Level Solutions Center at Florida International University.
He says recent rains have already saturated the amount of groundwater that can be absorbed in many parts of Florida. Storm surges will likely be worse because of a natural phenomenon called king tides, where tides are especially high when the moon is closest to Earth.
A large hurricane has not struck Florida’s Atlantic coast since Hurricane Andrew hit as a Category 5 storm in 1992. At the time, it was the costliest storm to ever strike the U.S.
Dorian is expected to hit as a Category 4 storm, meaning that the impacts may not be as catastrophic. But it will still cause damage.
In the 26 years since Hurricane Andrew, various parts of Florida have seen several inches of sea level rise. The rising waters likely won’t worsen what’s expected to be several feet of storm surge, says Obeysekera, but the hurricane’s impact could accelerate the coastal erosion.
So why hasn’t the east coast of Florida seen a major hurricane in 20 years?
Part of the reason may be due to a trend called Atlantic multidecadal oscillation, a natural cycle of warming and cooling thought to occur in the Atlantic Ocean on a roughly 20- to 40-year cycle. The oscillation could explain why Florida saw a spate of major hurricanes in the 1940s, Andrew in 1992, and now potentially Dorian.
“The other issue is that climate-change predictions are such that we could have stronger storms, and that’s also a factor,” says Obeysekera.
Experts caution against linking any one storm to climate change, but recentstudies show that warming waters could make hurricanes more intense, slower, and more likely to cause major flooding.
The little chopper will be the first rotorcraft ever to ply alien skies.
An engineer works on attaching NASA's Mars Helicopter to the belly of the Mars 2020 rover — which has been flipped over for that purpose — on Aug. 27, 2019, at the Jet Propulsion Laboratory in Pasadena, California.
The first-ever off-Earth helicopter just hooked up with its traveling companion.
Engineers at NASA's Jet Propulsion Laboratory (JPL) in Pasadena, California, attached the tiny Mars Helicopter to the agency's car-size Mars 2020 rover today (Aug. 28), agency officials announced.
The duo will launch together in July 2020 and touch down inside the Red Planet's Jezero Crater in February 2021. Once on Mars, the solar-powered, 4-lb. (1.8 kilograms) helicopter will detach and begin flying test sorties.
"Our job is to prove that autonomous, controlled flight can be executed in the extremely thin Martian atmosphere," Mars Helicopter project manager, of JPL, said in a statement. (Mars' air is just 1% as dense as that of Earth at sea level.)
"Since our helicopter is designed as a flight test of experimental technology, it carries no science instruments," she added. "But if we prove powered flight on Mars can work, we look forward to the day when Mars helicopters can play an important role in future explorations of the Red Planet."
"With this joining of two great spacecraft, I can say definitively that all the pieces are in place for a historic mission of exploration," Thomas Zurbuchen, associate administrator of the Science Mission Directorate at NASA's headquarters in Washington, D.C, said in the same statement. "Together, Mars 2020 and the Mars Helicopter will help define the future of science and exploration of the Red Planet for decades to come."
NASA plans to launch another rotorcraft soon as well — Dragonfly, which will soar through the thick atmosphere of Saturn's huge moon Titan. The life-hunting Dragonfly is scheduled to lift off in 2026 and land on Titan's frigid surface in 2034.
Mike Wall's book about the search for alien life, "Out There" (Grand Central Publishing, 2018; illustrated byKarl Tate), is out now. Follow him on Twitter @michaeldwall. Follow us on Twitter@Spacedotcom orFacebook.
Here at ZipSprout, we're all about learning what works with real, people-centered marketing - and sharing what we know! Read about what's worked for us here - with notes on our matches and experiences along the way.
Posted by: Garrett French The average event marketing opportunity costs a business between $500 and $1,000 to attend, and that doesn’t include labor, booth setup, or promotional items. For small … More
In addition to Local Sponsorships, we’ve also found local blogs to be a scalable publisher-type for hyper-local visibility and link building campaigns. This practical guide to local blog engagement … More
“We made offers on dozens of customers’ homes, many of which have since converted into contracts. I was deeply pleased with the events that ZipSprout procured for us. – Owen Boochever, Growth – Opendoor
We put together an infographic to summarize how corporate sponsorship is one of the most effective, and yet underused, marketing channels. Most businesses haven’t tried it! Will you?
One of the most commonly cited—but rarely explained—pieces of link building advice is to “take advantage of existing relationships” or “reach out to your contacts.” Claudia and Garrett go into detail on some specific approaches.
FODMAPs are found in a wide range of foods. This sample food list highlights some high and low FODMAP foods.*
*This table is not an exhaustive list of high and low FODMAP foods. For the world's most comprehensive database of FODMAP food information, please refer to our Monash University FODMAP Diet App
A low FODMAP Diet is NOT a diet for life
Science-based evidence has found that a low FODMAP diet can help with the symptoms of IBS. The great news is that following a low FODMAP diet isn’t a lifetime change. It is about monitoring your tolerance to FODMAP-rich foods and finding a diet that suits you and your symptoms.
Once you’re diagnosed with IBS, for optimal results, a dietitian can help you through a 3-step plan.
The reintroduction step helps you work out your tolerance to individual FODMAPs and eventually a combination of FODMAPs. For optimal results, a dietitian can help you work out the type and quantity of foods to reintroduce and monitor your progress.
After reintroducing certain foods back into your diet, you'll continue to monitor their effect on your symptoms and how the foods make you feel.
Although individual FODMAP tolerance varies, most people find that they don't have to be so strict about their FODMAP intake as they were during Step 1. This means you can be flexible with your diet while keeping your symptoms under control.
The goal is to achieve a balance between the avoidance of some high FODMAP foods and the reintroduction of better tolerated FODMAP-rich foods.
In most cases, people are able to reintroduce many high FODMAP foods back into their diet, but may not be able to eat them as often or in the same quantity as they did before.
There is no one-size-fits all that's why a FODMAP Personalization diet holds the key to getting on with your life!
It’s estimated that irritable bowel syndrome (or IBS) affects one in five Americans—or about 64 million people. The syndrome is associated with abdominal discomfort, with symptoms ranging from cramps and bloating to diarrhea and constipation.
IBS is often the result of significant stress. Typically, it begins during the adolescent years and rarely appears after age 50. The good news is that the condition is manageable. The key, of course, is to take care when deciding what to eat and drink…
1. Avoid Eating too Much in One Sitting
The larger the meal, the more you’re asking your body to digest. For a normal person, consuming a lot of food in one sitting is asking a lot of the digestive tract—it’s like handing a body builder a huge amount of weight and asking them to lift it. They can do it, but it won’t be easy.
People with IBS are at a disadvantage when trying to digest a lot of food all at once. That’s why they should try eating many smaller meals over the course of a day. Rather than having three square meals, make it five or six.
2. Take your Time Eating
Chances are that, when you were a kid, your mom or dad insisted that you eat slowly and properly chew your food before swallowing. That’s important because it can help you avoid choking, but it’s also a good tip for people dealing with irritable bowel syndrome.
You see, taking your time to eat allows your body to better manage digestion. Shoveling food in your mouth is the equivalent of a stampede of kids rushing into school in the morning. Your body, and the teachers, can better manage the situation if everyone moves slowly and methodically.
3. Eat a Full Breakfast
You’ve probably heard that breakfast is the most important meal of the day. There are a number of reasons for this. For one, people who eat breakfast are less likely to gorge themselves over the course of the day, reducing total calorie intake and helping with weight management.
But eating breakfast—and a full breakfast with moderate amounts of fiber—can also help people dealing with irritable bowel syndrome. That’s because eating breakfast stimulates the colon, encouraging the efficient movement of food through the body.
4. Avoid High-Fat Foods
There are many reasons to avoid high-fat, greasy foods like fast food hamburgers, baked goods, potato chips, and chocolate. For one, they can lead to weight gain (though not all food experts agree on this).
For people with irritable bowel syndrome, avoiding high-fat foods is important because these foods are often taxing on the stomach and intestines, raising the chances of cramping, diarrhea, constipation, and overall discomfort.
5. Take it Easy on the High-Fiber Foods
Just about every high-fiber product is advertised as being uber-healthy. And it’s true that fiber helps usher food through the body in an efficient way.
But too much fiber can pose a problem for people with irritable bowel syndrome. That’s because their bodies have a hard time digesting foods, especially those high in insoluble fiber. The trick is not to avoid fiber, but to consume it in moderation. Don’t switch to a super-high-fiber cereal and expect to feel great the following day.
6. Keep a Diet Diary
Everyone is different—some foods will prove troublesome, while others will pass through you without any issues. That’s why it’s important for everyone with irritable bowel syndrome to keep a diet diary carefully outlining which foods present problems, and which don’t.
Did those chicken wings make you feel nauseous? Were you surprised that the new cereal your trying didn’t cause discomfort? Keep note of these things and retrace your steps on a regular basis.
7. See your Doctor Regularly
Don’t suffer in silence. If you think you may be dealing with irritable bowel syndrome, talk to your doctor. Seek out a full physical examination and carefully outline your symptoms. Don’t be shy—remember, your doctor can only help if you’re clear about your diet and the symptoms you’re experiencing.
Keep in mind that your doctor may order tests to ensure that infection, inflammation, or a tumor are not responsible for the symptoms. Tests range from blood tests to stool tests and x-rays.
8. Consider Lactose-Free Dairy Products
Many people struggling with IBS report experiencing discomfort after consuming lactose, which can be found in most dairy products. Lactose is present in most forms of milk, cheese, and yogurt.
That’s why it may be a good idea to try lactose-free dairy products. Most grocery stores carry lactose-free milk, cheese, and yogurt. They may be more expensive and could taste slightly different, but it’s an easy way to avoid the complications caused by lactose.
9. Limit Consumption of Soda and Beer
Carbonated beverages like soda and beer can present significant problems for people with irritable bowel syndrome. That’s because carbonated drinks introduce gas into the intestines, which can increase the feeling of abdominal bloating and discomfort.
You don’t have to cut these drinks out of your diet entirely, but it’s worth limiting their consumption to see if this reduces the symptoms associated with IBS. It’s also worth keeping in mind that soda and beer often contain high amounts of sugar and carbohydrates.
10. Don’t Hold It
People with irritable bowel syndrome have very sensitive digestive systems. That’s why it’s best to obey the body when it needs to flush itself out. Don’t hold in a bowel movement—when it becomes clear this is necessary, get rid of the stool.
Otherwise, you risk inducing constipation. This, in itself, can present a problem because people with IBS may struggle to properly process laxatives, particularly strong ones (they may also become dependent on them). So, when you have to go…go.
Could paranormal activity be explained by beings entering our world from other dimensions? According to some Ancient Astronaut theorists, entities that have been described as ghosts, angels, and extraterrestrials are actually visitors from unseen realms — and they are among us even now.
The Hadith (a collection of Muslim narratives about the prophet Muhammad) includes the Hadith of Gabriel, which describes how archangel Gabriel (also known as Jibril in Islam) quizzes Muhammad about Islam to test how well he understands the religion. Gabriel appeared to Muhammad over a 23-year period to dictate the Qur'anword by word, Muslims believe.
In this Hadith, Gabriel appears in disguise, checking to make sure that Muhammad has received his messages about Islam correctly. Here's what happens:
The Hadith of Gabriel
The Hadith of Gabriel's tells the story: "Umar ibn al-Khattab (the second rightly guided caliph) reported: One day when we were with Allah’s [God’s] messenger, a man with extremely white clothing and very black hair came to us. No traces of travel were visible on him, and none of us recognized him. Sitting down before the Prophet, (peace and blessings be upon him) leaning his knees against his, and placing his hands on his thighs, the stranger said, 'Tell me, Muhammad, about Islam.'
The Prophet replied, 'Islam means that you should bear witness that there is no god but God and that Muhammad is Allah’s messenger, that you should perform the ritual prayer, pay the alms tax, fast during Ramadan, and make the pilgrimage to the Ka’aba at Mecca if you are able to go there.'
The man said, 'You have spoken the truth.' (We were amazed at this man’s questioning the Prophet and then declaring that he had spoken the truth).
The stranger spoke a second time, saying, 'Now tell me about faith.'
The Prophet replied, 'Faith means that you have faith in Allah, His angels, His books, His messengers and the Last Day and that you have faith in fate as it is measured out, both its good and evil aspects.'
Remarking that the Prophet again had spoken the truth, the stranger then said, 'Now tell me about virtue.'
The Prophet replied, 'Virtue—doing what is beautiful—means that you should worship Allah as if you see Him, for even if you do not see Him, He sees you.'
Yet again the man said, 'Tell me about the Hour (that is, the coming of the Day of Judgment).'
The Prophet replied, 'About that he who is questioned knows no more than the questioner.'
The stranger said, 'Well, then tell me about its signs.'
The Prophet replied, 'The slave girl will give birth to her mistress, and you will see the barefoot, the naked, the destitute, and the shepherds vying with each other in building.'
At that, the stranger went away.
After I had waited for a while, the Prophet spoke to me: 'Do you know who the questioner was, Umar?' I replied, 'Allah and His messenger know best.' The Prophet said, 'He was Jibril [Gabriel]. He came to teach you your religion.'"
Thoughtful Questions
In the preface to the book Questions And Answers About Islam by Fethullah Gülen, Muhammad Cetin writes that the Hadith of Gabriel helps readers learn how to ask thoughtful spiritual questions.
"Gabriel knew the answers to these questions, but his purpose of disguising himself and posing these questions was to help others attain this information. A question is asked for a certain purpose. Asking a question for the sake of displaying one’s own knowledge or asking merely to test the other person is worthless. If a question is asked for the purpose of learning in order to let others find out the information (as in the example of Gabriel above, the questioner may already know the answer) it can be considered a question that has been posed in the correct manner. Questions of this kind are like seeds of wisdom."
Defining Islam
The Hadith of Gabriel summarizes Islam's major tenets. Juan Eduardo Campo writes in the book Encyclopedia of Islam:
"The Hadith of Gabriel teaches that religious practice and belief are interrelated aspects of the Islamic religion – one cannot be accomplished without the other."
In their book The Vision of Islam, Sachiko Murata and William C. Chittick write that Gabriel's questions and Muhammad's answers help people Islam as three different dimensions working together:
"The hadith of Gabriel suggests that in the Islamic understanding, religion embraces right ways of doing things, right ways of thinking and understanding, and right ways of forming the intentions that lie behind the activity. In this hadith, the Prophet gives each of the three right ways a name. Thus one could say that 'submission' is religion as it pertains to acts, 'faith' is religion as it pertains to thoughts, and 'doing the beautiful' is religion as it pertains to intentions. These three dimensions of religion coalesce into a single reality known as Islam."
The Birth of Islam and the Proclamation by Muhammad of his Mission
When Muhammad was 40 years old, he was commanded by God, through His angel, Gabriel, to declare His Oneness to the idolaters and polytheists of the whole world, and to deliver the message of peace to an embattled humanity. In response to this command of Heaven, Muhammad launched the momentous program called Islam which was to change the destiny of mankind forever.
Before the Call came to him to declare the Unity of the Creator, Muhammad was in the habit of spending much time in meditation and reflection. To be free from interference and extraneous distractions, he frequently went to a mountain cave called Hira, three miles in the north-east of Makkah, and spent the long summer days there.
He was in Hira when one day the Archangel Gabriel appeared before him, and brought to him the tidings that God had chosen him to be His Last Messenger to this world, and had imposed upon him the duty of leading mankind out of the welter of sin, error and ignorance into the light of Guidance, Truth and Knowledge. Gabriel then bade Muhammad to “read” the following verses:
“Read in the name of thy lord and cherisher who created: Created man out of a clot of congealed blood. Read!And thy lord is most bountiful, He who taught the use of pen; Taught man that which he knew not”.
These five verses were the earliest revelation, and they came to Muhammad on the “Night of Power” or the “Blessed Night” in the month of Ramadan (the ninth month of the Islamic calendar) of the 40th year of the Elephant. They are at the beginning of the 96th chapter of Al-Qur’an al-Majid. The name of the chapter is Iqraa (Read) or ‘Alaq (the Clot of Congealed Blood).
The Night of Power or the Blessed Night occurs, according to tradition, during the last ten days of the month of Ramadan, and could be the 21st or 23rd or 25th or 27th of the month.
In their respective accounts of the reception by Muhammad of the First Revelation, the Sunni and the Shia Muslims are not in agreement. According to the Sunni tradition, the appearance of Gabriel surprised Muhammad, and when the former ordered him to read, he said, “I cannot read.” This happened thrice, and each time when Muhammad declared his inability to read, the angel pressed him hard to his bosom. Eventually, he was able to repeat the five verses whereupon the angel released him and disappeared
When Archangel Gabriel disappeared, Muhammad, who was now “ordained” the Messenger of Allah, descended from the cliffs of Hira, and repaired to his home in a state of great trepidation. He was shivering with cold, and when he entered his house, he asked his wife, Khadija, to cover him with a blanket which she did. When he had sufficiently recovered from the shock, he recounted to her the story of his strange encounter with Archangel Gabriel in the cave of Hira.
The traditional Sunni account of this incident is given in an article written by Shaykh Ahmad Zaki Hammad, Ph.D., captioned Be Hopeful, published in the monthly magazine, Islamic Horizons, of the Islamic Society of North America, Plainfield, Indiana, May-June 1987, as follows:
“The Prophet (pbuh) in the early stages in Makkah, feared that the revelation experience was an evil touch preying upon him, playing with him mentally, upsetting his tranquillity and peace of mind. He was afraid that one of the jinn had touched him. He expressed this to Khadija. His fear increased to the point that – and please don't be surprised by an authentic report in Bukhari – the Prophet (pbuh) preferred to take his own life rather than to be touched by evil, to be tampered with, corrupted, or polluted.”
But according to the accounts of the Shia Muslims, Muhammad Mustafa, far from being surprised or frightened by the appearance of Gabriel, welcomed him as if he had been expecting him. Gabriel brought the tidings that Allah had chosen him to be His Last Messenger to Mankind, and congratulated him on being selected to become the recipient of the greatest of all honors for a mortal in this world.
Muhammad had no hesitation in accepting the mission of prophethood nor he had any difficulty in repeating the verses of the First Revelation. He read them or repeated them effortlessly, spontaneously. Gabriel, in fact, was no stranger to him, and he also knew that his own raison d’être was to carry out the mission imposed upon him by God as His Messenger. He was “mission-oriented”even before Gabriel’s visit. Gabriel only gave him the signal to begin.
The Shia Muslims also say that one thing that Gabriel didn't have to do, was to apply physical pressure on Muhammad to read. If he did, it would truly be a bizarre mode of imparting to Muhammad the ability to read – by squeezing him or choking him.
They further maintain that Muhammad Mustafa did not contemplate suicide at any time in his life, not even in its most desolate moments; and that it never occurred to him that he could ever be touched by “evil” or that he could be “corrupted” or “polluted.”
Nevertheless, Muhammad felt alarm at the magnitude of the task ahead of him. He realized that in the execution of his duty, he would be confronted by the massive, formidable and determined opposition of the pagans of the whole world. The state of his anxiety was almost palpable. He was, therefore, in a somber frame of mind as he left the cave to return home. And he did ask Khadija to drape him in a blanket as he sat down to recapitulate the events in Hira to her.
When Khadija heard the story that Muhammad told her, she comforted him and reassured him by saying: “O son of my uncle, be of good cheer. Allah has chosen you to be His messenger. You are always kind to your neighbors, helpful to your kinsfolk, generous to the orphans, the widows and the poor, and friendly to the strangers. Allah will never forsake you.”
It is possible that Muhammad was momentarily overweighedby the thought of his accountability to Allah in carrying the enormous burden of his new responsibilities, but when he heard Khadija's soothing words, he immediately felt the tensions within him decompressing. She reassured him and convinced him that with God's Hand on his shoulder, he would rise equal to his duties and would overcome all obstacles.
After a brief interval, Gabriel appeared once again before Muhammad when the latter was in the cave of Hira, and presented to him the second Revelation which reads as follows:
O Thou wrapped up (in a mantle)! Arise and deliver thy warning! And thy lord do thou magnify.(Chapter 74; verses 1,2,3)
The commandment from Heaven to “arise and warn” was the signal to Muhammad (the wrapped up in a blanket) to begin his work. Gabriel expounded to him his new duties the foremost of which was to destroy the worship of false gods, and to plant the banner of Tauheed – the doctrine of the Unity of the Creator – in the world; and he had to invite mankind to the True Faith – Islam. Islam means to surrender to Allah, and to acknowledgeMuhammad as His slave and His messenger.
That evening Muhammad returned home conscious and conscientious of his new duty that he had to preach Islam, and that he had to begin from his own home – by preaching it to his wife.
Muhammad told Khadija about the second visit of Gabriel, and the duty imposed upon him by Allah to invite her to Islam. For Khadija, the antecedents and the moral integrity of her husband were an incontrovertible attestation that he was a divine messenger, and she readily accepted Islam. In fact, between her and Islam, an “ideological affinity” had pre-existed.
Therefore, when Muhammad Mustafa presented Islam to her, she at once “recognized” it, and rosily embraced it. She believed that the Creator was One, and that Muhammad was His messenger, and she declared:
I bear witness that there is no god but Allah; and I bear witness that Muhammad is His slave and His Messenger.
Muhammad, the new messenger of God, had won his first convert - Khadija – his wife. She was the first one, the very first to affirm her faith in Tauheed (Oneness of the Creator), and she was the very first to acknowledge Muhammad as God's messenger to all mankind. She was the first Muslima.
Muhammad “introduced” Islam to Khadija. He explained to her its meaning, and he initiated her into it.
The honor to be the first individual in the whole world to bear witness to God's unity and to acknowledge Muhammad's prophethood, belongs to Khadija for all time.
F. E. Peters
She (Khadija) was the first to accept the truth of his (Muhammad's) revelation, the premier Muslim after the Prophet himself. She encouraged and supported Muhammad during the first difficult years of his public preaching, and during the twenty-five years of their marriage he took no other wife. Theirs was, by any reasonable standard of judgment, a love match as well as a corporate partnership. (Allah's Commonwealth, New York)
As noted before, Ali ibn Abi Talib, was living at this time with his foster-parents, Muhammad and Khadija. The two sons of Muhammad and Khadija – Qasim and Abdullah had died in their infancy. After their death, they had adopted Ali as their son. Ali was five years old when he came into their house, and he was ten years old when Muhammad was ordained messenger of God. Muhammad and Khadija brought him up and educated him. In the years to come, he showed himself a most splendid “product” of the upbringing and education that Muhammad and Khadija gave him.
Sir William Muir
Shortly after the rebuilding of the Kaaba, Mohammed comforted himself for the loss of his infant son Casim by adopting Ali, the child of his friend and former guardian, Abu Talib. Ali, at this time not above five or six years of age, remained ever after with Mohammed, and they exhibited towards each other the mutual attachment of parent and child. (The Life of Mohammed, London, 1877)
Since Ali was a member of the Prophet's own family, he was inevitably the first, among males, to receive the message of Islam. He testified that God was One, and that Muhammad was His messenger. And he was very eager to stand behind Muhammad Mustafa to offer prayers.
Since then Muhammad was never seen at prayer except when Ali was with him. The boy also memorized the verses of Al-Qur’an al-Majid as and when they were revealed to Muhammad. In this manner, he literally grew up with Qur’an. In fact, Ali and Qur’an “grew up” together as “twins” in the house of Muhammad Mustafa and Khadija-tul-Kubra. Muhammad Mustafa, the Messenger of Allah, had found the first Muslima in Khadija, and the first Muslim in Ali ibn Abi Talib.
Muhammad ibn Ishaq
Ali was the first male to believe in the Apostle of God, to pray with him and to believe in his divine message, when he was a boy of ten. God favored him in that he was brought up in the care of the Apostle before Islam began. (The Life of the Messenger of God)
Muhammad Husayn Haykal
Ali was then the first youth to enter Islam. He was followed by Zayd ibn Harithah, Muhammad's client. Islam remained confined to the four walls of one house. Besides Muhammad himself, the converts of the new faith were his wife, his cousin, and his client. (The Life of Muhammad, Cairo, 1935)
Marmaduke Pickhtall
The first of all his (Muhammad's) converts was his wife, Khadija; the second his first cousin Ali, whom he had adopted; the third his servant Zeyd, a former slave. (Introduction to the Translation of Holy Qur’an, Lahore, Pakistan, 1975)
The third “witness” who accepted Islam, was Zayd ibn Haritha, the freedman of Muhammad, and a member of his household.
Tor Andre
Zaid was one of the first to accept Islam, in fact the third, after Khadija and Ali. (Mohammed, the Man and his Faith, 1960)
Ali ibn Abi Talib was the first male to accept Islam, and his precedence is beyond any question. Allama Muhammad Iqbal, the poet-philosopher of Indo-Pakistan, calls him, not the first, but “the foremost Muslim.”
Ibn Ishaq
From Yahya b. al-Ash'ath b. Qays al-Kindi from his father, from his grandfather Afiif: Al-Abbas b. Abdul Muttalib was a friend of mine who used to go often to the Yaman to buy aromatics and sell them during the fairs. While I was with him in Mina, there came a man in the prime of life and performed the full rites of ablution and then stood up and prayed. Then a woman came out and did her ablution and stood up and prayed. Then out came a youth just approaching manhood, did his ablutions, then stood up and prayed by his side.
When I asked Al-Abbas what was going on, and he said that it was his nephew Muhammad b. Abdullah b. Abdul Muttalib, who alleges that Allah has sent him as an Apostle; the other is my brother's son, Ali ibn Abi Talib, who has followed him in his religion; the third is his wife, Khadija daughter of Khuwaylid who also follows him in his religion. Afiif said after he had become a Muslim and Islam firmly established in his heart, ‘Would that I had been a fourth.!’ (The Life of the Messenger of God)
The fourth witness who accepted Islam, was Abu Bakr, a merchant of Makkah. In the beginning, Muhammad preached Islam secretly for fear of arousing the hostility of the idolaters. He invited only those people to Islam who were known to him personally.
It is said that through the efforts of Abu Bakr, the fourth Muslim, a few other Makkans also accepted Islam. Among them were Uthman bin Affan, a futurekhalifa of the Muslims; Talha, Zubayr, Abdur Rahman bin Auf, Saad bin Abi Waqqas, and Obaidullah ibn al-Jarrah.
For a long time the Muslims were very few in number and they did not dare to say their prayers in public. One of the early converts to Islam was Arqam bin Abi al-Arqam, a young man of the clan of Makhzoom. He was well-to-do and lived in a spacious house in the valley of Safa. Muslims gathered in his house to offer their congregational prayers. Three years passed in this manner. Then in the fourth year, Muhammad was commanded by God to invite his own folks to Islam openly.
And admonish thy nearest kinsmen. (Chapter 26; verse 214)
Muhammad's folks included all members of Banu Hashim and Banu al-Muttalib. He ordered his young cousin, Ali, to invite all their chief men to a banquet – forty of them.
When all the guests had gathered in a hall in the house of Abu Talib, and had partaken of their repast, Muhammad, the Messenger of God, rose to address them. One of the guests was Abu Lahab, an uncle of the Prophet on his father's side.
He must have heard rumors of what his nephew was doing in Makkah secretly, and probably guessed the reason why he had invited Banu Hashim to a feast. The Prophet had just begun to speak when he stood up; rudely interrupted him, and himself addressed the assembly, saying:
“Uncles, brothers and cousins! Do not listen to this “renegade,” and do not abandon your ancestral religion if he invites you to adopt a new one. If you do, then remember that you will rouse the anger of all Arabs against you. You do not have the strength to fight against all of them. After all, we are a mere handful. Therefore, it is in your own interest to be steadfast in your traditional religion.”
Abu Lahab, by his speech, succeeded in throwing confusion and disorder into the meeting so that everyone stood up milling around and jostling against each other. Then they began to leave, and soon the hall was empty.
Muhammad's first attempt to convert his own tribe to Islam had failed. But unfazed by this initial setback, he ordered his cousin, Ali, to invite the same guests a second time.
A few days later the guests came, and when they had eaten supper, Muhammad rose and spoke to them as follows:
“I offerthanks to Allah for His mercies. I praise Allah, and I seek His guidance. I believe in Him and I put my trust in Him. I bear witness that there is no god except Allah; He has no partners; and I am His messenger. Allah has commanded me to invite you to His religion by saying: And warn thy nearest kinsfolk. I, therefore, warn you, and call upon you to testify that there is no god but Allah, and that I am His messenger.
O ye sons of Abdul Muttalib, no one ever came to you before with anything better than what I have brought to you. By accepting it, your welfare will be assured in this world and in the Hereafter. Who among you will support me in carrying out this momentous duty? Who will share the burden of this work with me? Who will respond to my call? Who will become my vicegerent, my deputy and my wazir?”
There were forty guests in the hall. Muhammad paused to let the effect of his words sink into their minds but no one among them responded. At last when the silence became too oppressive, young Ali stood up and said that he would support the Messenger of God; would share the burden of his work; and would become his vicegerent, his deputy and his wazir. But Muhammad beckoned him to sit down, and said: “Wait! Perhaps someone older than you might respond to my call.”
Muhammad renewed his invitation but still no one seemed to stir, and he was greeted only by an uneasy silence. Once again, Ali offered his services but the Apostle still wishing that some senior member of the clan would accept his invitation, asked him to wait.
He then appealed to the clan a third time to consider his invitation, and the same thing happened again. No one in the assembly showed any interest. He surveyed the crowd and transfixed everyone in it with his gaze but no one moved. At length he beheld the solitary figure of Ali rising above the assembly of silent men, to volunteer his services to him.
This time Mohammed accepted Ali's offer. He drew him close, pressed him to his heart, and said to the assembly: “This is my wazir, my successor and my vicegerent. Listen to him and obey his commands.”
Edward Gibbon
Three years were silently employed in the conversion of fourteen proselytes, the first fruits of his (Mohammed's) mission; but in the fourth year he assumed the prophetic office, and resolving to impart to his family the light of divine truth, he prepared a banquet for the entertainment of forty guests of the race of Hashim.
‘Friends and kinsmen,' Mohammed said to the assembly, ‘I offer you, and I alone can offer, the most precious gifts, the treasures of this world and of the world to come. God has commanded me to call you to His service. Who among you will support my burden? Who among you will be my companion and my vizir? No answer was returned, till the silence of astonishment and doubt, and contempt was at length broken by the impatient courage of Ali, a youth in the fourteenth year of his age. ‘O Prophet,' he said, ‘I am the man. Whosoever rises against thee, I will dash out his teeth, tear out his eyes, break his legs, rip up his belly. O Prophet, I will be thy vizir over them.'
Mohammed accepted his offer with transport, and Abu Talib was ironically exhorted to respect the superior dignity of his son. (Decline and Fall of the Roman Empire)
Washington Irving
‘O children of Abd al-Muttalib,' cried he (Mohammed) with enthusiasm, ‘to you, of all men, has Allah vouchsafed these most precious gifts. In his name I offer you the blessings of this world, and endless joys hereafter. Who among you will share the burden of my offer? Who will be my brother, my lieutenant, my vizir?'
All remained silent; some wondering; others smiling with incredulity and derision. At length Ali, starting up with youthful zeal, offered himself to the service of the Prophet though modestly acknowledging his youth and physical weakness.
Mohammed threw up his arms around the generous youth, and pressed him to his bosom. 'Behold my brother, my vizir, my vicegerent,' exclaimed he, “Let all listen to his words, and obey him.” (The Life of Mohammed)
Sir Richard Burton
After a long course of meditation, fired with anger by the absurd fanaticism of the Jews, the superstitions of the Syrian and Arab Christians, and the horrid idolatries of his unbelieving countrymen, an enthusiast too – and what great soul has not been an enthusiast? – he (Mohammed) determined to reform those abuses which rendered revelation contemptible to the learned and prejudicial to the vulgar.
He introduced himself as one inspired to a body of his relations and fellow-clansmen. The step was a failure, except that it won for him a proselyte worth a thousand sabers in the person of Ali, son of Abu Talib. (The Jew the Gypsy and El Islam, San Francisco, 1898)
Ali had offered his services to Muhammad, the Messenger of God, and the latter had accepted them. To the elders of the tribe, Ali's conduct might have appeared rash and brazen but he soon proved that he had the grit to accomplish far more than others had the courage even to dream. The Messenger of God, on his part, accepted the offer not only with expressions of gratitude and joy but also declared that Ali was, from that moment, his vicegerent.
Muhammad's declaration was forthright and unequivocal. It is foolish to quibble, as some people do, that Ali's vicegerency of Muhammad, was confined to the tribe of Banu Hashim. But Muhammad himself did not restrict Ali's vicegerency to Banu Hashim. Ali was his vicegerent for all Muslims and for all time.
The banquet at which Muhammad, the Messenger of God, declared Ali to be his successor, is famous in history as “the banquet of Dhul-'Asheera.” This name comes from Al-Qur’an al-Majid itself (chapter 26; verse 214).
Strangely, Sir William Muir has called this historic event “apocryphal.” But what is “apocryphal” or so improbable about it? Could anything be more logical for the Messenger of God than to begin his work of propagating Islam at his own home, and with members of his own family and his own clan, especially after being expressly commanded by God towarn his nearest kinsmen?
The feast of Dhul-'Asheera at which Muhammad, the Apostle of God, designated Ali ibn Abi Talib, as his successor, is a historical event, and its authenticity has been affirmed, among others, by the following Arab historians:
1. Tabari, History, Vol. II,p. 217
2. Kamil ibn Atheer, History, Vol. II, p. 22
3. Abul Fida,History, Vol. I, p. 116
Sir William Muir
His (Mohammed's) cousin, Ali, now 13 or 14 years of age, already gave tokens of the wisdom and judgment which distinguished him in after life. Though possessed of indomitable courage, he lacked the stirring energy which would have rendered him an effective propagator of Islam. He grew up from a child in the faith of Mohammed, and his earliest associations strengthened the convictions of maturer years. (The life of Mohammed, London, 1877)
We have many reservations about Sir William Muir's statement that Ali “lacked the stirring energy that would have made him an effective propagator of Islam.” Ali did not lack energy or anything else. In all the crises of Islam, he was selected to carry out the most dangerous missions, and he invariably accomplished them.
As a missionary also, Ali was peerless. There was no one among all the companions of the Prophet who was a more effective propagator of Islam than he. He promulgated the first 40 verses of the Surah Bara'a (Immunity), the Ninth chapter of Al-Qur’an al-Majid, to the pagans at Makkah, as the first missionary of Islam, and as one representing the Apostle of God himself. And it was Ali who brought all the tribes of Yemen into the fold of Islam.
Muhammad, the Messenger of God, had brought up Ali as his own child, and if the latter had lacked anything, he would have known it. He declared Ali to be his wazir, his successor and his vicegerent at a time when no one could have foreseen the future of Islam. This only points up the unbounded confidence that the Prophet of Islam had in this stripling of fourteen years.
Ali symbolized the hopes and aspirations of Islam. In the great revolution which Muhammad, the Apostle of God, had launched at the feast of Dhul-'Asheera, he had mobilized the dynamism, and idealism, and the fervor and vigor of youth; Ali personified them all.
Two things had happened at the Feast. One was that the Prophet had brought Islam out in the open. Islam was no longer an “under-ground” movement; it had “surfaced.” At the feast of his kinsfolk, Muhammad had “crossed the Rubicon” and now there could be no turning back.
Has Antarctica served as a home base for extraterrestrial visitors to Earth for thousands of years? As human exploration of the frozen continent increases, are we about to come face to face with both the ruins of an ancient advanced civilization buried under the ice–and perhaps even aliens that still inhabit the frozen continent to this day?
The map's historical importance lies in its demonstration of the extent of global exploration of the New World by approximately 1510, and in its claim to have used a map of Christopher Columbus, otherwise lost, as a source. Piri also stated that he had used ten Arab sources and four Indian maps sourced from the Portuguese. More recently, the map has been the focus of claims for the pre-modern exploration of the Antarctic coast.
Signing your work is just as important as making the form itself. In this class I'll show you different ways to sign your work. Tools and Materials Underglaze Wax Resist Carving Tool Brush Your Stamp Small Tip Squeeze Bottle Sponge Water
There’s a language that sits a layer beneath code, and it yearns to be explored
At the time of writing, “which programming language should I learn” yields 517 million search results. Each page will go on about the advantages one language has over the others, and 90% of them will end up recommending Python or JavaScript.
If I may be so bold, I would like to formally disagree with all 517 million of these results and suggest that the first programming language you should learn is logic.
Knowing how to code just doesn’t cut it anymore. The market is so saturated with bootcamp graduates that the “junior software developer” position has been wiped from existence. To succeed today, you need to know how to code and have a logical mindset to boot.
My First Computer Science Lesson
My first exposure to Computer Science was an elective I took in 10th grade. On day one, I was elated to see a wide spread of ice cream and a variety of sundae toppings before me. After we all took our seats, my teacher proclaimed:
“Today, we’re going to be making sundaes. Under one condition: you have to write a list of specific instructions on how to prepare your sundae — then I’ll follow them.”
No problem, I thought, this will be a breeze. In under a minute, I jotted down the perfect set of sundae-making instructions:
Scoop three scoops of black raspberry ice cream into a bowl
Pour two tablespoons of hot fudge into said bowl
Put whipped cream into the bowl
Place sprinkles and a cherry on top of the sundae
Then my teacher — the computer in this lovely metaphor — put on the most accurately sarcastic display I’ve ever seen. She started viciously stabbing the ice cream carton, lid intact, unable to penetrate its tough exterior.
“OK, remove the lid first,” I said, desperate for a treat.
“You failed to provide me with those instructions, so, unfortunately, I failed to make you a sundae, NEXT!”
Fast-forward to attempt #2
Open the black raspberry ice cream by removing the lid
Scoop three scoops of black raspberry ice cream into a bowl
Open the hot fudge and pour two tablespoons into the bowl
Open the whipped cream and add some to the bowl
Place sprinkles and a cherry on top of the sundae
This time I was sure I had it. I even went ahead and ensured each item was opened before adding it to my masterpiece.
She opened the lid, scooped three scoops, and put them into the bowl. At last, my nascent sundae was finally coming into fruition. Then she opened the hot fudge and placed two tablespoons into my bowl. Not two tablespoons of hot fudge, mind you — two actual spoons, and no hot fudge. I failed to be specific enough — again. When all was said and done, I was handed a bowl of ice cream laden with two metal spoons, a solid canister of whipped cream, and about 300 sprinkles.
I think by this point it finally clicked: the computer is a purely logical entity. It has no context and makes no assumptions. It responds to a very specific set of instructions and follows them to a T.
My final set of sundae-making instructions was a verbose, but necessary, disaster:
If they are not already, open each of the following: Black Raspberry Ice Cream, Hot Fudge, Sprinkles, and Whipped Cream
Aquire a bowl from the stack and place it in front of you
Grab the ice cream scoop and, one at a time, scoop three scoops of black raspberry ice cream into the bowl. Place the scoop down when done
Aquire the hot fudge spoon if not already in your possession, then fetch two tablespoons of hot fudge and place them into the bowl, one at a time, and put down the hot fudge when done
Turn the whipped cream upside down, press your finger against the nozzle over the bowl for 3 seconds, and return the bottle to its resting position
Sprinkle approximately 40 sprinkles over the bowl and return the shaker to its upright position when done
Fetch a single cherry from the cherry jar and place it delicately on top of the sundae
Hand the sundae to the student along with a spoon
That last bullet was extremely important because she started eating my sundae without it.
This is the reality of computer programming. Providing intense sets of detailed instructions to a computer. In essence, this is what all programming languages decompose into — instructions.
The Software Development Career Path
Software development is now at a point where it’s too broad to discuss as a single industry, just as “software developer” is too broad a job title. Two developers can be equally marketable while having disjointed skill sets, implying there is more to a career in development than the mere ability to code. There’s an attribute skilled developers have that is universal and separate from programming— logic.
The best developers are experts in critical thinking. This is essential because the majority of software projects are undocumented, splintered disasters. They require a critical thinker to piece information together and fill in the gaps when needed. The developers who lag behind are those who cannot connect the dots.
All this culminates to another bold statement, this time in bold: The fundamentals of computer science are, and will always be, paramount to coding ability.
Popular languages come and go with the tide. Frameworks become deprecated, and companies react to shifting demands by mixing up their tech stack. The one thing that never changes? Fundamentals — that’s literally their definition!
How to Improve Logical Thinking
For those who can’t quite trek a mountain for deep thought, consider these tools to improve your programmatic critical thinking:
Know your run time complexities
Also referred to as Big-O, the runtime complexity of a program can be expressed as the number of steps taken on any instance in relation to the size of the input (n). Keeping perpetual tabs on the runtime of your programs is step one.
Know your data structures
Data structures are at the heart of every complex program. Knowing which structure to use in what scenario is an art of its own. Data structures tie directly into runtime complexities, as picking the wrong structure can send your programs to a grinding halt. Searching an Array for a value is O(n), which means it gets more expensive to use Arrays as the size of your input increases. Hash lookups are O(1), so the lookup time for a Hash key will be constant, regardless of the number of keys in said Hash.
I’ve had candidates argue that an Array has a faster search time than a Hash. This was an immediate signal not to hire them — know your data structures.
You cannot become a master violinist without excessively playing the violin. Sites like HackerRank, CodeWars, CoderByte, TopCoder, and LeetCodehave thousands of challenge problems designed to test your knowledge of data structures and algorithms. The best approach I’ve found to using these sites is to take your own shot at solving the problem, host your solutions on Github, and then look at the top solutions for that problem to see how others approached it. Which brings me to my last point:
View others’ code
The greatest mistake you can make in your software development journey is to go it alone. Software development is a largely crowdsourced effort. We build standards together, make mistakes together, and learn what works over time (by failing a lot). Taking the time to read skilled developers’ code will always pay off. Just make sure it’s good code.
The best advice I can leave you with is to never feel ashamed of what you don’t (yet) know. As I mentioned, this industry is massive, its number of languages extreme, and the content dense. It takes a great deal of time and effort to build an understanding, even more to gain proficiency, and an immense amount more to gain mastery. I’ll let you know when I get there.
Form 990-N (e-Postcard) is an annual electronic notice most small tax-exempt organizations (annual gross receipts normally $50,000 or less) are eligible to file instead of Form 990 or Form 990-EZ. (Users may also download a complete list.) Data posting date: 08-12-2019
Leaving for Cape Cod from home on Sunday, 8/11 around 8 or 9 AM. Check in starts at 3PM, The White Porch Inn in Provincetown.
Coming back on the 14th, Wednesday
NC
Leaving on the 16th around 6 or 6:30. Plane leaving from Newark 8/16 at 8:30 arriving to Asheville at 10:33 PM
Leaving from Asheville to Florida on the 21st, Wednesday. Plane leaves at 3:11 PM and lands around 5:06 PM
FL
Leaving for Newark on the 25th, on Sunday. Plane leaves at 6:00 AM and lands 8:50 AM
In NCHotels A,B,C
A) Clarion Inn Asheville Airport
Breakfast is included
Check in: Friday August, 16 after 4:00 PM
Check out: Saturday August, 17 until 12:00 PM
Phone: 828-684-1213
550 Airport Road, Fletcher, NC 28732
Clarion Inn Asheville Airport
B) Best Western Smoky Mountain Inn
Breakfast is included
Check-in: Saturday, August 17, 2019 after 4:00 PM
Check-out: Monday, August 19, 2019 until 11:00 AM
130 Shiloh Trail, Waynesville, NC 28786
Phone number: 828 456 4402
C) Pisgah Inn
Monday August 19 to Wednesday August 21 Upstairs double beds
Free breakfast at the restaurant
Check in is 3:00pm and check out is at 11:00am on the day of your departure.
Arrival Date Monday August 19
Departure Date Wednesday August 21
ROS indigo Installation tutorial: http://wiki.ros.org/indigo/Installation/Ubuntu (*NOTE: make sure to first update dpkg(sudo apt-get update && sudo apt-get install dpkg), as the original version of Ubuntu Trusty does not support LZMA archives in debian pkgs)
Note, in order for ROS turtlebot simulator to work, it is recommended that you install ubuntu 14.04 and ROS indigo.
Use the navigation stack to create a map of the Gazebo world and start navigation based on it. This tutorial shows you how to use its SLAM (gmapping) package to build a map, and then autonomously navigate from point A to point B
Walking upside-down requires a careful balance of adhesion and weight, and specialized trekking tools to combat the constant tug of gravity.
Each fly foot has two fat footpads that give the insect plenty of surface area with which to cling. The adhesive pads on the feet, called pulvilli, come equipped with tiny hairs that have spatula-like tips. These hairs are called setae.
Scientists once thought that the curved shape of the hairs suggested that flies used them to grip onto the ceiling. In fact, the hairs produce a glue-like substance made of sugars and oils.
Sticky proof
A research team from the German Max Planck Institute for Metals Research recently studied more than 300 species of wall-climbing insects and watched them all leave behind sticky footprints.
Mystery Monday
Each Monday, this LiveScience series explores an amazing aspect of the world around you. Previous articles:
Mystery Monday
Each Monday, this LiveScience series explores an amazing aspect of the world around you. Previous articles:
"There are over one million insect species," team leader Stanislav Gorb told LiveScience. "We suppose that all of them have the secretion, but it is difficult to be 100 percent sure."
Gorb presented the findings at the Annual Meeting of the Society for Experimental Biology in April.
Flies need sticky feet to walk on ceilings, but not so sticky that they get stuck upside down. So each foot comes with a pair of claws that help hoist the gooey foot off the wall.
Flies use several different techniques to get unstuck: pushing, twisting, and peeling its footpads free.
"Methods involving peeling are always the best, because they require less energy to break the contact," Gorb said.
The combination of the feet hairs' rounded tips, the oily fluid, and a four-feet-on-the-floor rule help the inverted insect take steps in the right direction.
Lessons for robofly
Following in the fly's footsteps, robots are on their way to climbing walls.
Gorb's research team worked with a robotics group from Case Western Reserve University to design robotic feet that mimic a fly's footing.
On the bottom of the feet of a 3-ounce robot that's all legs, scientists tacked on a sticky, furry manmade material that resembles the hairy surface of a fly foot. The researchers also taught the robot how to gently peel its foot off a glass wall, just like a demure insect.
"It's the first time a robot has climbed glass in a way that was inspired by an animal," said mechanical engineer Roger Quinn.
This assignment allows optional partnering. If you choose to do this, you must follow the pair programming guidelines. Please click the link and review them before you begin. Your partner can be from another precept (but ISC students may only partner with other ISC students). Please note that writing code with a partner without following the pair programming instructions is a violation of the course collaboration policy. All writing of code, comments, analysis and uploading to the dropbox should be done together from start to finish. If you come to office hours alone, you can get advice, but you may not change any code until both partners are together.
Frequently Asked Questions
What are the main goals of this assignment? You will (i) solve a fundamental problem in computational biology, (ii) learn about the analysis of algorithms, and (iii) learn about a powerful programming paradigm known as dynamic programming.
How do I read in the two input strings from the file? Use StdIn.readString() and redirection as usual.
How do I access the length of a string s? The ith character? Use s.length() and s.charAt(i), respectively. As with arrays, indices start at 0. We'll learn about this notation for manipulating (String) objects in Section 3.1. For this assignment, this is all you'll need to know about objects.
Can I assume that the input characters will always be A, C, G or T? NO! Your program should work equally well for any letter, upper case or lower case.
What's a StringIndexOutOfBoundsException? It's just like an ArrayOutOfBoundsException. It results from invoking s.charAt(i) with an illegal value of i.
How could I get a NullPointerException? Did you forget to allocate memory for opt[][]?
How do I declare and initialize a two dimensional array in Java? Review the end of Section 1.4 in Intro to Programming.
It seems strange to define x[i..M] to be the substring consisting of x[i] through x[M-1] instead of x[i] through x[M]. Is this a typo? It's a little strange, but no, it's not a typo. It's consistent with Java's indexing notation where the left endpoint is inclusive and the right endpoint is exclusive.
Which alignment should I print out if there are two or more optimal ones? Output any one you like.
Should gaps be handled by penalty()? The solution we think is clearest does not call penalty() on gaps, since a gap is not a character. Of course, the alignment output should use the '-'symbol to denote a gap, and the inputs we give you will never contain '-' (only alphanumeric characters are used), so if you find it convenient for penalty() to recognize '-' as a gap, you are permitted to do so.
Where can I learn more about dynamic programming and backtracking? The LCS (longest common subsequence) problem described in booksite section 9.6 is an example of a dynamic programming problem on strings with backtracking. However, it is different from the current problem in many ways, so do not simply mimic the code without understanding what it does. The websheet exercises for this week include several dynamic programming exercises starting from a basic level, including KnapsackBacktrack which is an example of backtracking.
Memory, Timing, and Operating System Issues
What does OutOfMemoryError mean? When Java runs, it requests a certain amount of memory from the operating system. The exact amount depends on the version of Java and your computer, but can vary from 64MB to 1024MB (1GB). After Java has started, the total size of all variables in use cannot be larger than what it originally requested. Trying to do so causes anOutOfMemoryError.
For this assignment, the largest test cases use huge arrays, and Java needs to ask for enough memory from the operating system. To explicitly ask for for more (or less) memory, use the -Xmxflag. For example, to request 500 megabytes (500 MB) of memory for a run, use
java-introcs -Xmx500m EditDistance < input.txt
Here 500m means 500 MB. You should adjust this number depending on the amount of memory your computer has and the size of the arrays you will need for the data set you are running. The amount 500MB should get you through ecoli10000.txt. To run ecoli20000.txt you will need to request more memory. (How much? The readme asks you to estimate this.)
What does "Could not reserve enough space for object heap" mean? This occurs if you use -Xmx with a value that is larger than the amount of available physical memory. Additionally, due to address space limitations, some 32-bit versions of Windows also will give this error if you try to request more than approximately 1.5GB, no matter how much physical memory is installed.
How do I determine how much physical memory is installed on my computer? On Mac, select About this Mac from the Apple menubar. On Windows, press Windows-R (or Run on the Start menu), enter msinfo32 and look for total physical memory.
How can I measure how long my program takes on each file?To measure the running time of your program, there are a few techniques.
and use a stopwatch. We redirect the output to a file to prevent printing text from becoming a bottleneck.
A second technique, which we think probably best suits the needs of this application, is to use the -Xprof runtime switch, which asks Java to print out timing data about the run. To use this with output redirection, type
The timing information will appear at the end of the file output.txt, and you want the "flat profile" for main. The line will look like
Flat profile of 4.5 secs (15 total ticks): main
but these numbers are made up and yours will be different. We don't care about the ticks.Piping can be useful here. You can skip the output file in the previous step by piping your output to another program that will look for "Flat profile". and it should print out the time (and throw away all the other program output). On a Mac, run
This find/grep command searches through all of whatever text it is fed and only prints out the lines containing the text main. Type man grep (in Terminal) or find /? (in Command Prompt) for more information.
As a third technique, you can use Stopwatch objects, see Repeat.java for an example. We'll explain more about objects later in the course.
Finally, you may elect to directly use System.currentTimeMillis() as shown in lecture.
How do I use a cluster machine in Friend 016/017? See this page for general instructions. Please also read the first bullet point for the question immediately below.
My timing data do not fit a polynomial hypothesis. What could I be doing wrong?
If you are running your program and accessing the data files from the Windows H: drive (especially if via a wireless network) or ~ on a cluster Mac (Friend 016/017), the bottleneck for medium-sized test cases might be the network latency instead of the dynamic programming algorithm! Do one of the following:
Use a Stopwatch or System.currentTimeMillis() to specifically isolate the time taken after the input is read (after all calls to StdIn) and before any output is printed. Remember to remove the time printing statements before submitting the final version of your code.
Or, copy all files to a folder on a local hard drive. We don't recommend this on a cluster (Friend 016/017) machine.
Or, report your problems and the data you obtained, and use the readme's sample data for analysis instead.
When you run out of physical memory, your operating system may start using your hard drive as another form of storage. Accessing information from the hard drive is substantially slower than main memory, and you may be observing this effect. Avoid running extraneous complicated programs (media players, file sharing clients, word processors, web browsers, etc) while doing the timing tests if this seems to be a problem.
Make sure you are using output redirection or piping (as in the examples above) to prevent printing text from becoming a bottleneck.
Very small test cases are hard to use since the Java virtual machine takes a nontrivial amount of time to start, and since the processor "cache" may make small test cases run an order of magnitude faster than expected. If in doubt, use the test cases that take between 0.1 and 10.0 seconds.
Testing and Debugging
Testing. To help you check the part of your program that generates the alignment, there are many test files in the sequence directory.
Many of the small files are designed so that it is easy for you to determine what the correct answer should be by hand. Test your program on these cases to see that it gets these easy cases right.
Here are the optimal edit distances of several of the supplied files.
The test case worked through as an example in the assignment description, which is the same as the example10.txt file, has a unique optimal alignment. (Some test inputs like "xx y" have more than one optimal alignment.) So your code should give the exact same output on example10.txt as in the assignment page.
Here are two more test cases with unique optimal alignments:
% java-introcs EditDistance < endgaps7.txt % java-introcs EditDistance < fli10.txt
Edit distance = 4 Edit distance = 2
a - 2 T T 0
t t 0 G G 0
a a 0 G G 0
t t 0 C T 1
t t 0 G G 0
a a 0 G G 0
t t 0 A T 1
- a 2 A A 0
C C 0
T T 0
In addition, we require that you generate one small input file of your own to be used for testing special cases. Create a new input file with some interesting property. Then test your code using your file and make sure your program behaves as expected. For example, when we tested your RGBtoCMYK program in an earlier assignment, our special case was when R=0, G=0, B=0. In NBody, one of our special cases was a system with only 1 body. Include a description of your special test case in your readme.txt file.
Possible Progress Steps
These are purely suggestions for how you might make progress. You do not have to follow these steps.
Download sequence.zip to your computer and unzip it, as described on the assignment page. It contains test files and the readme templates.
Write the following two short helper methods.
// return the penalty for aligning character a with character b public static int penalty(char a, char b) // return the min of 3 integers public static int min(int a, int b, int c)
You will call these from your main method to compute penalties and to determine which of the three cases yields the minimum edit distance.
Write the main() method in EditDistance.java to read in the two strings from standard input, using the method StdIn.readString(). For debugging, print them to standard output.
Declare and initialize the (M+1)-by-(N+1) array opt[][]. Include the base cases. Print out the 2D array to check your work.To print the matrix out in nicely formatted columns, use
System.out.printf("%3d", opt[i][j]);
with nested for loops. Remember to remove this debugging print section before submitting the final version of your program.
Now, it's time to implement the crucial dynamic programming part. First read the dynamic programming portion of Section 9.6 and make sure you understand how dynamic programming works. Think carefully about the order in which you will perform the computation since this is critical. Hint: first fill in the base case of opt[i][j], e.g., when i = M or j = N. Now, fill in the remaining values using a nested loop. Test that it works by printing out the contents of opt.
Now, figure out how to recover the optimal alignment by backtracing.This is an iterative process. At each step we look to see which path choice we should make. Using the example from the assignment we start at i = 0, j=0 where x[i] = 'A' and y[i] = 'T'. The choices are to print "A -" and move down with a gap cost of 2, "- T" and move right with a gap cost of 2, or "A T" and move diagonally with a mismatch cost of 1. We know to pick "A T" because 7 - 6 = 1. This is the only choice which matches the matrix. (It is possible to have more than one choice which matches the matrix. In that case, either choice will lead to the same optimal edit distance.)
Test this part thoroughly. For example, one corner case to test is to make sure that you print out the ENTIRE alignment, even when one sequence finishes before the other. (Use lastXgaps9.txt and lastYgaps9.txt to test.)
Measure the time that your program takes on the sample runs indicated in the readme. For help on performing timing tests, see above.
Use the doubling method to estimate the running time as a polynomial function of the input size.
Reviewing Your Program
Does each static method have a comment indicating what it does?
Are there any hardwired constants? Do they appear in multiple methods? The cleanest solution to this is to use the static class constant
private static int MISMATCH = 1;
(and two other similar ones for gaps and matches). This makes your code easy to use if a different set of penalties is desired.
Enrichment
The idea of dynamic programming was first advanced by Bellman (1957). Levenshtein (1966) formalized the notion of edit distance. Needleman-Wunsch (1970) were the first to apply edit distance and dynamic programming for aligning biological sequences, and our algorithm is essentially the one proposed in their seminal paper. The widely-used Smith-Waterman(1981) algorithm is quite similar, but solves a slightly different problem (local sequence alignment instead of global sequence alignment).
The same technology is employed in spell checkers and to identify plagiarism in many courses (including this one).
With a little work, you can compute the optimal cost in quadratic time but using only linear space (do we need the whole opt matrix?) With more work, you can also compute the optimal alignment in linear space (and quadratic time). This is known as Hirschberg's algorithm (1975).
This assignment allows optional partnering. If you choose to do this, you must follow the pair programming guidelines. Please click the link and review them before you begin. Your partner can be from another precept (but ISC students may only partner with other ISC students). Please note that writing code with a partner without following the pair programming instructions is a violation of the course collaboration policy. All writing of code, comments, analysis and uploading to the dropbox should be done together from start to finish. If you come to office hours alone, you can get advice, but you may not change any code until both partners are together.
Write a program to compute the optimal sequence alignment of two DNA strings. This program will introduce you to the field of computational biology in which computers are used to do research on biological systems. Further, you will be introduced to a powerful algorithmic design paradigm known as dynamic programming.
Biology review. A genetic sequence is a string formed from a four-letter alphabet {Adenine (A), Thymine (T), Guanine (G), Cytosine (C)} of biological macromolecules referred to together as the DNA bases. A gene is a genetic sequence that contains the information needed to construct a protein. All of your genes taken together are referred to as the human genome, a blueprint for the parts needed to construct the proteins that form your cells. Each new cell produced by your body receives a copy of the genome. This copying process, as well as natural wear and tear, introduces a small number of changes into the sequences of many genes. Among the most common changes are the substitution of one base for another and the deletion of a substring of bases; such changes are generally referred to as point mutations. As a result of these point mutations, the same gene sequenced from closely related organisms will have slight differences.
The problem. Through your research you have found the following sequence of a gene in a previously unstudied organism.
A A C A G T T A C C
What is the function of the protein that this gene encodes? You could begin a series of uninformed experiments in the lab to determine what role this gene plays. However, there is a good chance that it is a variant of a known gene in a previously studied organism. Since biologists and computer scientists have laboriously determined (and published) the genetic sequence of many organisms (including humans), you would like to leverage this information to your advantage. We'll compare the above genetic sequence with one which has already been sequenced and whose function is well understood.
T A A G G T C A
If the two genetic sequences are similar enough, we might expect them to have similar functions. We would like a way to quantify "similar enough."
Edit-distance. In this assignment we will measure the similarity of two genetic sequences by their edit distance, a concept first introduced in the context of coding theory, but which is now widely used in spell checking, speech recognition, plagiarism detection, file revisioning, and computational linguistics. We align the two sequences, but we are permitted to insert gaps in either sequence (e.g., to make them have the same length). We pay a penalty for each gap that we insert and also for each pair of characters that mismatch in the final alignment. Intuitively, these penalties model the relative likeliness of point mutations arising from deletion/insertion and substitution. We produce a numerical score according to the following table, which is widely used in biological applications:
operation
cost
insert a gap
2
align two characters that mismatch
1
align two characters that match
0
Here are two possible alignments of the strings x = "AACAGTTACC" and y = "TAAGGTCA":
x y cost
------------
A T 1
A A 0
C A 1
A G 1
G G 0
T T 0
T C 1
A A 0
C - 2
C - 2
---
8
x y cost
------------
A T 1
A A 0
C - 2
A A 0
G G 0
T G 1
T T 0
A - 2
C C 0
C A 1
---
7
The first alignment has a score of 8, while the second one has a score of 7. The edit-distance is the score of the best possible alignment between the two genetic sequences over all possible alignments. In this example, the second alignment is in fact optimal, so the edit-distance between the two strings is 7. Computing the edit-distance is a nontrivial computational problem because we must find the best alignment among exponentially many possibilities. For example, if both strings are 100 characters long, then there are more than 10^75 possible alignments.
We will explain a recursive solution which is an elegant approach. However it is far too inefficient because it recalculates each subproblem over and over. Once we have defined the recursive definition we can redefine the solution using a dynamic programming approach which calculates each subproblem once.
A recursive solution. We will calculate the edit-distance between the two original strings x and y by solving many edit-distance problems on smaller suffixes of the two strings. We use the notation x[i] to refer to character i of the string. We also use the notation x[i..M] to refer to the suffix of x consisting of the characters x[i], x[i+1], ..., x[M-1]. Finally, we use the notation opt[i][j] to denote the edit distance of x[i..M] and y[j..N]. For example, consider the two strings x = "AACAGTTACC" and y = "TAAGGTCA" of length M = 10 and N = 8, respectively. Then, x[2] is 'C', x[2..M] is "CAGTTACC", and y[8..N] is the empty string. The edit distance of x and y is opt[0][0].
Now we describe a recursive scheme for computing the edit distance of x[i..M] and y[j..N]. Consider the first pair of characters in an optimal alignment of x[i..M] with y[j..N]. There are three possibilities:
The optimal alignment matches x[i] up with y[j]. In this case, we pay a penalty of either 0 or 1, depending on whether x[i] equals y[j], plus we still need to align x[i+1..M] with y[j+1..N]. What is the best way to do this? This subproblem is exactly the same as the original sequence alignment problem, except that the two inputs are each suffixes of the original inputs. Using our notation, this quantity is opt[i+1][j+1].
The optimal alignment matches the x[i] up with a gap. In this case, we pay a penalty of 2 for a gap and still need to align x[i+1..M] with y[j..N]. This subproblem is identical to the original sequence alignment problem, except that the first input is a proper suffix of the original input.
The optimal alignment matches the y[j] up with a gap. In this case, we pay a penalty of 2 for a gap and still need to align x[i..M] with y[j+1..N]. This subproblem is identical to the original sequence alignment problem, except that the second input is a proper suffix of the original input.
The key observation is that all of the resulting subproblems are sequence alignment problems on suffixes of the original inputs. To summarize, we can compute opt[i][j] by taking the minimum of three quantities:
This equation works assuming i < M and j < N. Aligning an empty string with another string of length k requires inserting k gaps, for a total cost of 2k. Thus, in general we should set opt[M][j] = 2(N-j) and opt[i][N] = 2(M-i). For our example, the final matrix is:
| 0 1 2 3 4 5 6 7 8
x\y | T A A G G T C A -
-----------------------------------
0 A | 7 8 10 12 13 15 16 18 20
1 A | 6 6 8 10 11 13 14 16 18
2 C | 6 5 6 8 9 11 12 14 16
3 A | 7 5 4 6 7 9 11 12 14
4 G | 9 7 5 4 5 7 9 10 12
5 T | 8 8 6 4 4 5 7 8 10
6 T | 9 8 7 5 3 3 5 6 8
7 A | 11 9 7 6 4 2 3 4 6
8 C | 13 11 9 7 5 3 1 3 4
9 C | 14 12 10 8 6 4 2 1 2
10 - | 16 14 12 10 8 6 4 2 0
By examining opt[0][0], we conclude that the edit distance of x and y is 7.
A dynamic programming approach. A direct implementation of the above recursive scheme will work, but it is spectacularly inefficient. If both input strings have N characters, then the number of recursive calls will exceed 2^N. To overcome this performance bug, we use dynamic programming. (Read the first section of Section 9.6 for an introduction to this technique.) Dynamic programming is a powerful algorithmic paradigm, first introduced by Bellman in the context of operations research, and then applied to the alignment of biological sequences by Needleman and Wunsch. Dynamic programming now plays the leading role in many computational problems, including control theory, financial engineering, and bioinformatics, including BLAST (the sequence alignment program almost universally used by molecular biologists in their experimental work). The key idea of dynamic programming is to break up a large computational problem into smaller subproblems, store the answers to those smaller subproblems, and, eventually, use the stored answers to solve the original problem. This avoids recomputing the same quantity over and over again. Instead of using recursion, use a nested loop that calculates opt[i][j] in the right order so that opt[i+1][j+1], opt[i+1][j], and opt[i][j+1] are all computed before we try to compute opt[i][j].
Recovering the alignment itself. The above procedure describes how to compute the edit distance between two strings. We now outline how to recover the optimal alignment itself. The key idea is to retrace the steps of the dynamic programming algorithm backwards, re-discovering the path of choices (highlighted in red in the table above) from opt[0][0] to opt[M][N]. To determine the choice that led to opt[i][j], we consider the three possibilities:
The optimal alignment matches x[i] up with y[j]. In this case, we must have opt[i][j] = opt[i+1][j+1] if x[i] equals y[j], or opt[i][j] = opt[i+1][j+1] + 1 otherwise.
The optimal alignment matches x[i] up with a gap. In this case, we must have opt[i][j] = opt[i+1][j] + 2.
The optimal alignment matches y[j] up with a gap. In this case, we must have opt[i][j] = opt[i][j+1] + 2.
Depending on which of the three cases apply, we move diagonally, down, or right towards opt[M][N], printing out x[i] aligned with y[j] (case 1), x[i] aligned with a gap (case 2), or y[j]aligned with a gap (case 3). In the example above, we know that the first T aligns with the first A because opt[0][0] = opt[1][1] + 1, but opt[0][0] ≠ opt[1][0] + 2 and opt[0][0] ≠ opt[0][1] + 2. The optimal alignment is:
x y cost
------------
A T 1
A A 0
C - 2
A A 0
G G 0
T G 1
T T 0
A - 2
C C 0
C A 1
API specification. Your program EditDistance.java must be organized as a library of static methods with the following API:
public class EditDistance
--------------------------------------------------------------------------------
int penalty(char a, char b) // return the penalty for aligning char a and char b
int min(int a, int b, int c) // return the min of 3 integers
void main(String[] args) // read 2 strings from standard input.
// compute and print the edit distance between them.
// output an optimal alignment and associated penalties.
Your program. Write a program EditDistance.java that reads, from standard input, two strings of characters. (Although, in the application described, the characters represent genetic sequences, your program should handle any sequence of alphanumeric characters.) Your program should then compute and print the edit distance between the two strings. Finally, it should recover the optimal alignment and print it out along with the individual penalties, using the following format:
The first line should contain the edit distance, preceded by the text "Edit distance = ".
Each subsequent line should contain a character from the first string, followed by the paired character from the second string, followed by the associated penalty. Use the character '-'to indicate a gap in either string.
Here is a sample execution:
% java-introcs EditDistance < example10.txt
Edit distance = 7
A T 1
A A 0
C - 2
A A 0
G G 0
T G 1
T T 0
A - 2
C C 0
C A 1
The .zip file for this week contains short test data files and actual genomic data files, as well as the readme.txt for this assignment (recall the unzipping instructions here). Or, you can use thesequence directory course ftp site.
Be sure to test thoroughly using the short test files and the longer actual data files. Also, make up a short test file of your own and describe it in your readme.txt file.
Analysis. After you have tested your program using not only the example provided above, but also the many short test data files in the sequence subdirectory, it is time to analyze its running time and memory usage. Using the genomic data sets referred to in the readme.txt file, use the doubling method to estimate the running time (in seconds) of your program as a function of the lengths of the two input strings M and N. For simplicity, assume M = N in your analysis. Also analyze the memory usage (in bytes). Be sure to enter these results in your readme and answer all the questions.
Submission. One partner should submit the files EditDistance.java and readme.txt (including the analysis and test data you created). If you are partnering, the second partner should only submit this abbreviated partner readme.txt.
This assignment was created by Thomas Clarke, Robert Sedgewick, Scott Vafai and Kevin Wayne.
The idea of calling one function from another immediately suggests the possibility of a function calling itself. The function-call mechanism in Java supports this possibility, which is known as recursion.
Your first recursive program.
The "Hello, World" for recursion is the factorial function, which is defined for positive integers n by the equation
n!=n×(n−1)×(n−2)×…×2×1n!=n×(n−1)×(n−2)×…×2×1
The quantity n! is easy to compute with a for loop, but an even easier method in Factorial.java is to use the following recursive function:
public static long factorial(int n) {
if (n == 1) return 1;
return n * factorial(n-1);
}
We can trace this computation in precisely the same way that we trace any sequence of function calls.
Our factorial() implementation exhibits the two main components that are required for every recursive function.
The base case returns a value without making any subsequent recursive calls. It does this for one or more special input values for which the function can be evaluated without recursion. For factorial(), the base case is n = 1.
The reduction step is the central part of a recursive function. It relates the value of the function at one (or more) input values to the value of the function at one (or more) other input values. Furthermore, the sequence of input values values must converge to the base case. For factorial(), the value of n decreases by 1 for each call, so the sequence of input values converges to the base case.
Mathematical induction.
Recursive programming is directly related to mathematical induction, a technique for proving facts about natural numbers. Proving that a statement involving an integer n is true for infinitely many values of n by mathematical induction involves the following two steps:
The base case: prove the statement true for some specific value or values of n (usually 0 or 1).
The induction step: assume that the statement to be true for all positive integers less than n, then use that fact to prove it true for n.
Such a proof suffices to show that the statement is true for infinitely many values of n: we can start at the base case, and use our proof to establish that the statement is true for each larger value of n, one by one.
Euclid's algorithm.
The greatest common divisor (gcd) of two positive integers is the largest integer that divides evenly into both of them. For example, the gcd(102, 68) = 34.
We can efficiently compute the gcd using the following property, which holds for positive integers p and q:
If p > q, the gcd of p and q is the same as the gcd of q and p % q.
The static method gcd() in Euclid.java is a compact recursive function whose reduction step is based on this property.
In the towers of Hanoi problem, we have three poles and n discs that fit onto the poles. The discs differ in size and are initially stacked on one of the poles, in order from largest (disc n) at the bottom to smallest (disc 1) at the top. The task is to move all ndiscs to another pole, while obeying the following rules:
Move only one disc at a time.
Never place a larger disc on a smaller one.
Recursion provides just the plan that we need: First we move the top n−1 discs to an empty pole, then we move the largest disc to the other empty pole, then complete the job by moving the n−1 discs onto the largest disc. TowersOfHanoi.java is a direct implementation of this strategy.
Exponential time.
Let T(n) be the number of move directives issued by TowersOfHanoi.java to move n discs from one peg to another. Then, T(n) must satisfy the following equation:
T(n)=2T(n−1) for n>1, with T(1)=1T(n)=2T(n−1) for n>1, with T(1)=1
Such an equation is known in discrete mathematics as a recurrence relation. We can often use them to derive a closed-form expression for the quantity of interest. For example, T(1) = 1, T(2) = 3, T(3) = 7, and T(4) = 15. In general, T(n) = 2n − 1. Assuming the monks move discs at the rate of one per second, it would take them more 5.8 billion centuries to solve the 64-disc problem.
Gray code.
An n-bit Gray code is a list of the 2n different n-bit binary numbers such that each entry in the list differs in precisely one bit from its predecessor. The n bit binary reflected Gray code is defined recursively as follows:
the n−1 bit code, with 0 prepended to each word, followed by
the n−1 bit code in reverse order, with 1 prepended to each word.
The 0-bit code is defined to be null, so the 1-bit code is 0 followed by 1.
Beckett.java uses an n-bit Gray code to print stage directions for an n-character play in such a way that characters enter and exit one at a time so that each subset of characters on the stage appears exactly once.
Recursive graphics.
Simple recursive drawing schemes can lead to pictures that are remarkably intricate. For example, an H-tree of order n is defined as follows: The base case is null for n = 0. The reduction step is to draw, within the unit square three lines in the shape of the letter H four H-trees of order n − 1, one connected to each tip of the H with the additional provisos that the H-trees of order n − 1 are centered in the four quadrants of the square, halved in size.
Htree.java takes a command-line argument n, and plots to standard drawing an H-tree of order n. An H-tree is a simple example of a fractal: a geometric shape that can be divided into parts, each of which is (approximately) a reduced size copy of the original.
Brownian bridge.
Brownian.java produces a function graph that approximates a simple example of fractional Brownian motion known as Brownian bridge. You can think of this graph as a random walk that connects the two points (x0, y0) and (x1, y1), controlled by a few parameters. The implementation is based on the midpoint displacement method, which is a recursive plan for drawing the plot within the x-interval [x0, x1]. The base case (when the size of the interval is smaller than a given tolerance) is to draw a straight line connecting the two endpoints. The reduction case is to divide the interval into two halves, proceeding as follows:
Compute the midpoint (xm, ym) of the interval.
Add to the y-coordinate ym of the midpoint a random value δ, drawn from the Gaussian distribution with mean 0 and a given variance.
Recur on the subintervals, dividing the variance by a given scaling factor s.
The shape of the curve is controlled by two parameters: the volatility (initial value of the variance) controls the distance the graph strays from the straight line connecting the points, and the Hurst exponent controls the smoothness of the curve.
Pitfalls of recursion.
With recursion, you can write compact and elegant programs that fail spectacularly at runtime.
Missing base case. The recursive function in NoBaseCase.java is supposed to compute harmonic numbers, but is missing a base case:
If you call this function, it will repeatedly call itself and never return.
No guarantee of convergence. Another common problem is to include within a recursive function a recursive call to solve a subproblem that is not smaller than the original problem. For example, the recursive function in NoConvergence.javagoes into an infinite recursive loop for any value of its argument (except 1).
public static double harmonic(int n) {
if (n == 1) return 1.0;
return harmonic(n) + 1.0/n;
}
Excessive memory requirements. If a function calls itself recursively an excessive number of times before returning, the memory required by Java to keep track of the recursive calls may be prohibitive. The recursive function inExcessiveMemory.java correctly computes the nth harmonic number. However, calling it with a huge value of n will lead to a StackOverflowError.
public static double harmonic(int n) {
if (n == 0) return 0.0;
return harmonic(n-1) + 1.0/n;
}
Excessive recomputation. The temptation to write a simple recursive program to solve a problem must always be tempered by the understanding that a simple program might require exponential time (unnecessarily), due to excessive recomputation. For example, the Fibonacci sequence
Fn=Fn−1+Fn−2 for n≥2, with F0=0 and F1=1Fn=Fn−1+Fn−2 for n≥2, with F0=0 and F1=1
A novice programmer might implement this recursive function to compute numbers in the Fibonacci sequence, as in Fibonacci.java:
// Warning: spectacularly inefficient.
public static long fibonacci(int n) {
if (n == 0) return 0;
if (n == 1) return 1;
return fibonacci(n-1) + fibonacci(n-2);
}
However, this program is spectacularly inefficient! To see why it is futile to do so, consider what the function does to compute fibonacci(8) = 21. It first computes fibonacci(7) = 13 and fibonacci(6) = 8. To compute fibonacci(7), it recursively computes fibonacci(6) = 8again and fibonacci(5) = 5. Things rapidly get worse. The number of times this program computes fibonacci(1)when computing fibonacci(n) is precisely Fn.
Dynamic programming.
A general approach to implementing recursive programs, The basic idea of dynamic programming is to recursively divide a complex problem into a number of simpler subproblems; store the answer to each of these subproblems; and, ultimately, use the stored answers to solve the original problem. By solving each subproblem only once (instead of over and over), this technique avoids a potential exponential blow-up in the running time.
Top-down dynamic programming. In top-down dynamic programming, we store or cache the result of each subproblem that we solve, so that the next time we need to solve the same subproblem, we can use the cached values instead of solving the subproblem from scratch. TopDownFibonacci.java illustrates top-down dynamic programming for computing Fibonacci numbers.
Bottom-up dynamic programming. In bottom-up dynamic programming, we compute solutions to all of the subproblems, starting with the “simplest” subproblems and gradually building up solutions to more and more complicated subproblems.BottomUpFibonacci.java illustrates bottom-up dynamic programming for computing Fibonacci numbers.
public static long fibonacci(int n) {
long[] f = new long[n+1];
f[0] = 0;
f[1] = 1;
for (int i = 2; i <= n; i++)
f[i] = f[i-1] + f[i-2];
return f[n];
}
Longest common subsequence problem. Given two strings x and y, we wish to compute their (LCS). If we delete some characters from x and some characters from y, and the resulting two strings are equal, we call the resulting string a common subsequence. The LCS problem is to find a common subsequence of two strings that is as long as possible. For example, the LCS of GGCACCACG and ACGGCGGATACG is GGCAACG, a string of length 7.
- - G G C - - A - C C A C G
A C G G C G G A T - - A C G
Longest common subsequence recurrence. Now we describe a recursive formulation that enables us to find the LCS of two given strings s and t. Let m and n be the lengths of s and t, respectively. We use the notation s[i..m) to denote the suffix of s starting at index i, and t[j..n) to denote the suffix of t starting at index j.
If s and t begin with the same character, then the LCS of s and t contains that first character. Thus, our problem to reduces to finding the LCS of the suffixes s[1..m) and t[1..n).
If s and t begin with different characters, both characters cannot be part of a common subsequence, so can safely discard one or the other. In either case, the problem reduces to finding the LCS of two strings—either s[0..m) and t[1..n) or s[1..m) and t[0..n).
In general, if we let opt[i][j] denote the length of the LCS of the suffixes s[i..m) and t[j..n), then the following recurrence holds:
opt[i][j] = 0 if i = m or j = n
= opt[i+1][j+1] + 1 if s[i] = t[j]
= max(opt[i][j+1], opt[i+1][j]) otherwise
Dynamic programming solution.LongestCommonSubsequence.java begins with a bottom-up dynamic programming approach to solving this recurrence.
The final challenge is to recover the longest common subsequence itself, not just its length. The key idea is to retrace the steps of the dynamic programming algorithm backward, rediscovering the path of choices (highlighted in gray in the diagram) from opt[0][0] to opt[m][n]. To determine the choice that led to opt[i][j], we consider the three possibilities:
The character s[i] matches t[j]. In this case, we must have opt[i][j] = opt[i+1][j+1] + 1, and the next character in the LCS is s[i]. We continue tracing back from opt[i+1][j+1].
The LCS does not contain s[i]. In this case, opt[i][j] = opt[i+1][j] and we continue tracing back from opt[i+1][j].
The LCS does not contain t[j]. In this case, opt[i][j] = opt[i][j+1] and we continue tracing back from opt[i][j+1].
Exercises
Given four positive integers a, b, c, and d, explain what value is computed by gcd(gcd(a, b), gcd(c, d)).Solution: the greatest common divisor of a, b, c, and d.
Explain in terms of integers and divisors the effect of the following Euclid-like function.
public static boolean gcdlike(int p, int q) {
if (q == 0) return (p == 1);
return gcdlike(q, p % q);
}
Solution: Returns whether p and q are relatively prime.
Consider the following recursive function.
public static int mystery(int a, int b) {
if (b == 0) return 0;
if (b % 2 == 0) return mystery(a+a, b/2);
return mystery(a+a, b/2) + a;
}
What are the values of mystery(2, 25) and mystery(3, 11)? Given positive integers a and b, describe what value mystery(a, b) computes. Answer the same question, but replace + with * and replace return 0 with return 1.
Solution: 50 and 33. It computes a*b. If you replace + with *, it computes a^b.
Write a program AnimatedHtree.java that animates the drawing of the H-tree.
Next, rearrange the order of the recursive calls (and the base case), view the resulting animation, and explain each outcome.
Creative Exercises
Binary representation. Write a program IntegerToBinary.java that takes a positive integer n (in decimal) as a command-line argument and prints its binary representation. Recall, in Binary.java, we used the method of subtracting out powers of 2. Now, use the following simpler method: repeatedly divide 2 into n and read the remainders backwards. First, write a while loop to carry out this computation and print the bits in the wrong order. Then, use recursion to print the bits in the correct order.
Permutations. Write a program Permutations.java that take an integer command-line argument n and prints all n! permutations of the n letters starting at a (assume that n is no greater than 26). A permutation of n elements is one of the n! possible orderings of the elements. As an example, when n = 3 you should get the following output (but do not worry about the order in which you enumerate them):
bca cba cab acb bac abc
Permutations of size k. Write a program PermutationsK.java that two command-line arguments n and k, and prints out all P(n,k)=n!(n−k)!P(n,k)=n!(n−k)! permutations that contain exactly k of the n elements. Below is the desired output when k = 2 and n= 4 (again, do not worry about the order):
ab ac ad ba bc bd ca cb cd da db dc
Combinations. Write a program Combinations.java that takes an integer command-line argument n and prints all 2ncombinations of any size. A combination is a subset of the n elements, independent of order. As an example, when n = 3, you should get the following output:
a ab abc ac b bc c
Note that your program needs to print the empty string (subset of size 0).
Combinations of size k. Write a program CombinationsK.java that takes two command-line arguments n and k, and prints all C(n,k)=n!k!(n−k)!C(n,k)=n!k!(n−k)! combinations of size k. For example, when n = 5 and k = 3, you should get the following output:
abc abd abe acd ace ade bcd bce bde cde
Alternate solution using arrays instead of strings: Comb2.java.
Recursive squares. Write a program to produce each of the following recursive patterns. The ratio of the sizes of the squares is 2.2:1. To draw a shaded square, draw a filled gray square, then an unfilled black square.
Gray code. Modify Beckett.java to print the Gray code (not just the sequence of bit positions that change).Solution: GrayCode.java uses Java's string data type; GrayCodeArray.java uses a boolean array.
Animated towers of Hanoi animation. Write a program AnimatedHanoi.java that uses StdDraw to animate a solution to the towers of Hanoi problem, moving the discs at a rate of approximately 1 per second.
Collatz function. Consider the following recursive function in Collatz.java, which is related to a famous unsolved problem in number theory, known as the Collatz problem or the 3n + 1 problem.
public static void collatz(int n) {
StdOut.print(n + " ");
if (n == 1) return;
if (n % 2 == 0) collatz(n / 2);
else collatz(3*n + 1);
}
For example, a call to collatz(7) prints the sequence
7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1
as a consequence of 17 recursive calls. Write a program that takes a command-line argument n and returns the value of i < n for which the number of recursive calls for collatz(i) is maximized. Hint: use memoization. The unsolved problem is that no one knows whether the function terminates for all integers (mathematical induction is no help because one of the recursive calls is for a larger value of the argument).
Brownian island. B. Mandelbrot asked the famous question How long is the coast of Britain? Modify Brownian.java to get a program BrownianIsland.java that plots Brownian islands, whose coastlines resemble that of Great Britain. The modifications are simple: first, change curve() to add a random Gaussian to the x-coordinate as well as to the y-coordinate; second, change main() to draw a curve from the point at the center of the canvas back to itself. Experiment with various values of the arguments to get your program to produce islands with a realistic look.
Plasma clouds. Write a recursive program PlasmaCloud.java to draw plasma clouds, using the method suggested in the text.
public static int mcCarthy(int n) {
if (n > 100) return n - 10;
else return mcCarthy(mcCarthy(n+11));
}
Determine the value of mcCarthy(50) without using a computer. Give the number of recursive calls used by mcCarthy()to compute this result. Prove that the base case is reached for all positive integers n or find a value of n for which this function goes into a recursive loop.
Recursive tree. Write a program Tree.java that takes a command-line argument n and produces the following recursive patterns for n equal to 1, 2, 3, 4, and 8.
Web Exercises
Does Euclid.java still work if the inputs can be negative? If not, fix it. Hint: Recall that % can return a negative integer if the first input is negative. When calling the function, take the absolute value of both inputs.
Write a recursive program GoldenRatio.java that takes an integer input N and computes an approximation to the golden ratio using the following recursive formula:
f(N) = 1 if N = 0
= 1 + 1 / f(N-1) if N > 0
Redo, but do not use recursion.
Discover a connection between the golden ratio and Fibonacci numbers. Hint: consider the ratio of successive Fibonacci numbers: 2/1, 3/2, 8/5, 13/8, 21/13, 34/21, 55/34, 89/55, 144/89, ...
Consider the following recursive function. What is mystery(1, 7)?
public static int mystery(int a, int b) {
if (0 == b) return 0;
else return a + mystery(a, b-1);
}
Will the function in the previous exercise terminate for every pair of integers a and b between between 0 and 100? Give a high level description of what mystery(a, b) returns, given integers a and b between 0 and 100.
Answer: Yes, the base case is b = 0. Successive recursive calls reduce b by 1, driving it toward the base case. The function mystery(a, b) returns a * b. Mathematically inclined students can prove this fact via induction using the identity ab = a + a(b-1).
Consider the following function. What does mystery(0, 8) do?
public static void mystery(int a, int b) {
if (a != b) {
int m = (a + b) / 2;
mystery(a, m);
StdOut.println(m);
mystery(m, b);
}
}
Answer: infinite loop.
Consider the following function. What does mystery(0, 8) do?
public static void mystery(int a, int b) {
if (a != b) {
int m = (a + b) / 2;
mystery(a, m - 1);
StdOut.println(m);
mystery(m + 1, b);
}
}
Answer: stack overflow.
Repeat the previous exercise, but replace if (a != b) with if (a <= b).
What does mystery(0, 8) do?
public static int mystery(int a, int b) {
if (a == b) StdOut.println(a);
else {
int m1 = (a + b ) / 2;
int m2 = (a + b + 1) / 2;
mystery(a, m1);
mystery(m2, b);
}
}
What does the following function compute?
public static int f(int n) {
if (n == 0) return 0;
if (n == 1) return 1;
if (n == 2) return 1;
return 2*f(n-2) + f(n-3);
Write a program Fibonacci2.java that takes a command-line argument N and prints out the first N Fibonacci numbers using the following alternate definition:
F(n) = 1 if n = 1 or n = 2
= F((n+1)/2)2 + F((n-1)/2)2 if n is odd
= F(n/2 + 1)2 - F(n/2 - 1)2 if n is even
What is the biggest Fibonacci number you can compute in under a minute using this definition? Compare this toFibonacci.java.
Write a program that takes a command-line argument N and prints out the first N Fibonacci numbers using the following method proposed by Dijkstra:
Prove by mathematical induction that the alternate definitions of the Fibonacci function given in the previous two exercises are equivalent to the original definition.
Write a program Pell.java that takes a command-line argument N and prints out the first N Pell numbers: p0 = 0, p1 = 1, and for n >= 2, pn = 2 pn-1 + pn-2. Print out the ratio of successive terms and compare to 1 + sqrt(2).
Consider the following function from program Recursion.java:
public static void mystery(int n) {
if (n == 0 || n == 1) return;
mystery(n-2);
StdOut.println(n);
mystery(n-1);
}
What does mystery(6) print out? Hint: first figure out what mystery(2), mystery(3), and so forth print out.
What would happen in the previous exercise if the base case was replaced with the following statement?
if (n == 0) return;
Consider the following recursive functions.
public static int square(int n) {
if (n == 0) return 0;
return square(n-1) + 2*n - 1;
}
public static int cube(int n) {
if (n == 0) return 0;
return cube(n-1) + 3*(square(n)) - 3*n + 1;
}
What is the value of square(5)? cube(5)? cube(123)?
Consider the following pair of mutually recursive functions. What does g(g(2)) evaluate to?
public static int f(int n) { public static int g(int n) {
if (n == 0) return 0; if (n == 0) return 0;
return f(n-1) + g(n-1); return g(n-1) + f(n);
} }
Write program to verify that (for small values of n) the sum of the cubes of the first n Fibonacci numbers F(0)^3 + F(1)^3 + ... + F(n)^3 equals (F(3n+4) + (-1)^n * 6 * f(n-1)) / 10, where F(0) = 1, F(1) = 1, F(2) = 2, and so forth.
Transformations by increment and unfolding. Given two integers a ≤ b, write a program Sequence.java that transforms a into b by a minimum sequence of increment (add 1) and unfolding (multiply by 2) operations. For example,
Hadamard matrix. Write a recursive program Hadamard.java that takes a command-line argument n and plots an N-by-N Hadamard pattern where N = 2n. Do not use an array. A 1-by-1 Hadamard pattern is a single black square. In general a 2N-by-2N Hadamard pattern is obtained by aligning 4 copies of the N-by-N pattern in the form of a 2-by-2 grid, and then inverting the colors of all the squares in the lower right N-by-N copy. The N-by-N Hadamard H(N) matrix is a boolean matrix with the remarkable property that any two rows differ in exactly N/2 bits. This property makes it useful for designing error-correcting codes. Here are the first few Hadamard matrices.
8 queens problem. In this exercise, you will solve the classic 8-queens problem: place 8 queens on an 8-by-8 chess board so that no two queens are in the same row, column, or diagonal. There are 8! = 40,320 ways in which no two queens are placed in the same row or column. Any permutation p[] of the integers 0 to 7 gives such a placement: put queen i in row i, column p[i]. Your program Queens.java should take an integer command-line argument n and enumerate all solutions to the n-queens problem by drawing the location of the queens in ASCII like the two solutions below.
Hint: to determine whether setting q[n] = i conflicts with q[0] through q[n-1]
if q[i] equals q[n]: two queens are placed in the same column
if q[i] - q[n] equals n - i: two queens are on same major diagonal
if q[n] - q[i] equals n - i: two queens are on same minor diagonal
Another 8 queens solver. Program Queens2.java solves the 8 queens problem by implicitly enumeration all n! permutations (instead of the n^n placements). It is based on program Permutations.java.
Euclid's algorithm and π. The probability that two numbers chosen from a large random set of numbers have no common factors (other than 1) is 6 / π2. Use this idea to estimate π. Robert Matthews use the same idea to estimate π by taken the set of numbers to be a function of the positions of stars in the sky.
Towers of Hanoi variant II. (Knuth-Graham and Pathashnik) Solve the original Towers of Hanoi problem, but with the extra restriction that you are not allowed to directly transfer a disk from A to C. How many moves does it take to solve a problem with n disks? Hint: move n-1 smallest disks from A to C recursively (without any direct A to C moves), move disk n from A to B, move n-1 smallest disks from C to A (without any direct A to C moves), move disk N from B to C, and move n-1 smallest disks from A to C recursively (without any direct A to C moves).
Towers of Hanoi variant III. Repeat the previous question but disallow both A to C and C to A moves. That is, each move must involve pole B.
Towers of Hanoi with 4 pegs. Suppose that you have a fourth peg. What is the least number of moves needed to transfer a stack of 8 disks from the leftmost peg to the rightmost peg? Answer. Finding the shortest such solution in general has remained an open problem for over a hundred years and is known as Reve's puzzle.
Another tricky recursive function. Consider the following recursive function. What is f(0)?
public static int f(int x) {
if (x > 1000) return x - 4;
else return f(f(x+5));
}
Checking if n is a Fibonacci number. Write a function to check if n is a Fibonacci number. Hint: a positive integer is a Fibonacci number if and only if either (5*n*n + 4) or (5*n*n - 4) is a perfect square.
Random infix expression generator. Run RandomExpression.java with different command-line argument p between 0 and 1. What do you observe?
A tricky recurrence. Define F(n) so that F(0) = 0 and F(n) = n - F(F(n-1)). What is F(100000000)?Solution: The answer is related to the Fibonacci sequence and the Zeckendorf representation of a number.
von Neumann ordinal. The von Neumann integer i is defined as follows: for i = 0, it is the empty set; for i > 0, it is the set containing the von Neumann integers 0 to i-1.
Write a program Ordinal.java with a recursive function vonNeumann() that takes a nonnegative integer N and returns a string representation of the von Neumann integer N. This is a method for defining ordinals in set theory.
Subsequences of a string. Write a program Subsequence.java that takes a string command-line argument s and an integer command-line argument k and prints out all subsequences of s of length k.
% java Subsequence abcd 3
abc abd acd bcd
Interleaving two strings. Given two strings s and t of distinct characters, print out all (M+N)! / (M! N!) interleavings, where M and N are the number of characters in the two strings. For example, if
s = "ab" t = "CD"
abCD CabD
aCbD CaDb
aCDb CDab
Binary GCD. Write a program BinaryGCD.java that finds the greatest common divisor of two positive integers using the binary gcd algorithm: gcd(p, q) =
p if q = 0
q if p = 0
2 * gcd(p/2, q/2) if p and q are even
gcd(p/2, q) if p is even and q is odd
gcd(p, q/2) if p is odd and q is even
gcd((p-q)/2, q) if p and q are odd and p >= q
gcd(p, (q-p)/2) if p and q are odd and p < q
Integer partitions. Write a program Partition.java that takes a positive integer N as a command-line argument and prints out all partitions of N. A partition of N is a way to write N as a sum of positive integers. Two sums are considered the same if they only differ in the order of their constituent summands. Partitions arise in symmetric polynomials and group representation theory in mathematics and physics.
Johnson-Trotter permutations. Write a program JohnsonTrotter.java that takes an integer command-line argument n and prints all n! permutations of the integer 0 through n-1 in such a way that consecutive permutations differ in only one adjacent transposition (similar to way Gray code iterates over combinations in such a way that consecutive combinations differ in only one bit).
Permutations in lexicographic order. Write a program PermutationsLex.java that take a command-line argument N and prints out all N! permutations of the integer 0 through N-1 in lexicographic order.
% java PermutationsLex 3
012
021
102
120
201
210
Derangements. A derangement is a permutation p[] of the integers from 0 to N-1 such that p[i] doesn't equal i for any i. For example there are 9 derangements when N = 4: 1032, 1230, 1302, 2031, 2301, 2310, 3012, 3201, 3210. Write a program to count the number of derangements of size N using the following recurrence: d[N] = (N-1) (d[N-1] + d[N-2]), where d[1] = 0, d[2] = 1. The first few terms are 0, 1, 2, 9, 44, 265, 1854, 14833, 133496, and 1334961.
Tribonacci numbers. The tribonacci numbers are similar to the Fibonacci numbers, except that each term is the sum of the three previous terms in the sequence. The first few terms are 0, 0, 1, 1, 2, 4, 7, 13, 24, 44, 81. Write a program to compute tribonacci numbers. What is the ratio successive terms? Answer. Root of x^3 - x^2 - x - 1, which is approximately 1.83929.
Sum of first n Fibonacci numbers. Prove by induction that the sum of the first n Fibonacci numbers F(1) + F(2) + ... + F(N) is F(N+2) - 1.
Combinational Gray code. Print out all combination of k of n items in such a way that consecutive combinations differ in exactly one element, e.g., if k = 3 and n = 5, 123, 134, 234, 124, 145, 245, 345, 135, 235, 125. Hint: use the Gray code, but only print out those integers with exactly k 1's in their binary representation.
Maze generation.Create a maze using divide-and-conquer: Begin with a rectangular region with no walls. Choose a random gridpoint in the rectangle and construct two perpendicular walls, dividing the square into 4 subregions. Choose 3 of the four regions at random and open a one cell hole at a random point in each of the 3. Recur until each subregion has width or height 1.
Plasma clouds. Program PlasmaCloud.java takes a command-line argument N and produces a random N-by-N plasma fractal using the midpoint displacement method.
Here's an 800-by-800 example. Here's a reference, including a simple 1D version. Note: some visual artifacts are noticeable parallel to the x and y axes. Doesn't have all of the statistical properties of 2D fractional Brownian motion.
Fern fractal. Write a recursive program to draw a fern or tree, as in this fern fractal demo.
Integer set partition. Use memoization to develop a program that solves the set partition problem for positive integer values. You may use an array whose size is the sum of the input values.
Voting power. John F. Banzhaf III proposed a ranking system for each coalition in a block voting system. Suppose party i control w[i] votes. A strict majority of the votes is needed to accept or reject a proposal. The voting power of party i is the number of minority coalitions it can join and turn it into a winning majority coalition. Write a program VotingPower.java that takes in a list of coalition weights as command-line argument and prints out the voting power of each coalition. Hint: use Schedule.java as a starting point.
Scheduling on two parallel machines. Program Schedule.java takes a command-line argument N, reads in N real number of standard input, and partitions them into two groups so that their difference is minimized.
Conway's sequence. Consider the following recursive function. f(n) = f(f(n-1)) + f(n-f(n-1)) for n > 2 and f(1) = f(2) = 1. Compute f(3). Write a Java program to compute the first 50 values of f(n) in the sequence. Use dynamic programming. Conway's sequence has many interesting properties and connects with Pascal's triangle, the Gaussian distribution, Fibonacci numbers, and Catalan numbers.
Running time recurrences. Use dynamic programming to compute a table of values T(N), where T(N) is the solution to the following divide-and-conquer recurrence. T(1) = 0, T(N) = N + T(N/2) + T(N - N/2) if N > 1.
Gas station optimization. You are driving from Princeton to San Francisco in a car that gets 25 miles per gallon and has a gas tank capacity of 15 gallons. Along the way, there are N gas stations where you can stop for gas. Gas station i is d[i] miles into the trip and sells gas for p[i] dollars per gallon. If you stop at station i for gas, you must completely fill up your tank. Assume that you start with a full tank and that the d[i] are integers. Use dynamic programming to find a minimum cost sequence of stops.
Unix diff. The Unix diff program compares two files line-by-line and prints out places where they differ. Write a program Diff.java that reads in two files specified at the command line one line at a time, computes the LCS on the sequence of constituent lines of each file, and prints out any lines corresponding to non-matches in the LCS.
Longest common subsequence of 3 strings. Given 3 strings, find the longest common subsequence using dynamic programming. What is the running time and memory usage of your algorithm?
Making change. Given A hundred dollar bills, B fifty dollar bills, C twenty dollar bills, D ten dollar bills, E five dollar bills, F one dollar bills, G half-dollars, H quarters, I dimes, J nickels, and K pennies, determine whether it is possible to make change for N cents. Hint: knapsack problem. (Greedy also works.)
Making change. Suppose that you are a cashier in a strange country where the currency denominations are: 1, 3, 8, 16, 22, 57, 103, and 526 cents (or more generally d0, d1, ..., dN-1. Describe a dynamic programming algorithm to make change for c cents using the fewest number of coins. Hint: the greedy algorithm won't work since the best way to change 114 cents is 57 + 57 instead of 103 + 8 + 3.
Longest increasing sequence. Given an array of N 64-bit integers, find the longest subsequence that is strictly increasing.Hint. Compute the longest common subsequence between the original array and a sorted version of the array where duplicate copies of an integer are removed.
Longest common increasing sequence. Computational biology. Given two sequences of N 64-bit integers, find the longest increasing subsequence that is common to both sequences.
Activity selection with profits. Job i has start time s_i, finish time f_i and profit p_i. Find best subset of jobs to schedule.
Diff. Write a program that reads in two files and prints out their diff. Treat each line as a symbol and compute an LCS. Print out those lines in each file that aren't in the LCS.
Text justification. Write a program that takes a command line argument N, reads text from standard input, and prints out the text, formatted nicely with at most N characters per line. Use dynamic programming.
Viterbi algorithm. Given a directed graph where each edge is labeled with a symbol from a finite alphabet. Is there a path from one distinguished vertex x that matches the characters in the string s? Dynamic programming. A(i, v) = 0 or 1 if there is a path from x to v that consumes the first i characters of s. A(i, v) = max (A(i-1, u) : (u, v) in E labeled with s[i]).
Viterbi algorithm. Speech recognition, handwriting analysis, computational biology, hidden Markov models. Suppose each edge leaving v has a probability p(v, w) of being traversed. Probability of a path is the product of the probability on that path. What is most probable path? Dynamic programming.
Smith–Waterman algorithm. Local sequence alignment.
Binomial coefficients (brute-force). The binomial coefficient C(n, k) is the number of ways of choosing a subset of k elements from a set of n elements. It arises in probability and statistics. One formula for computing binomial coefficients is C(n, k) = n! / (k! (n-k)!). This formula is not so amenable to direct computation because the intermediate results may overflow, even if the final answer does not. For example C(100, 15) = 253338471349988640 fits in a 64-bit long, but the binary representation of 100! is 525 bits long.Pascal's identity expresses C(n, k) in terms of smaller binomial coefficients:
SlowBinomial.java fails spectacularly for medium n or k, not because of overflow, but rather because the same subproblems are solved repeatedly.
// DO NOT RUN THIS CODE FOR LARGE INPUTS
public static long binomial(int n, int k) {
if (k == 0) return 1;
if (n == 0) return 0;
return binomial(n-1, k) + binomial(n-1, k-1);
}
Binomial coefficients (dynamic programming). Write a program Binomial.java that takes two command-line arguments n and k and uses bottom-up dynamic programming to compute C(n, k).
David Carroll(American) vs Cambridge Analytica (legal challenge in Britain asking force the court to turn in all the data they harvested on him
Demands: full disclosure, where they get the data, how they process it, who they share with and do we have the right to opt out?
Analytica claims they have 5,000 point on every American.
"When people see the extent of the surveillance. I think they are going to be shocked"
Analytica: we don't use Facebook data, they use Facebook as a platform to advertise.
[News] Mr. Alexander Nix, did you mislead the Parliament with data from Facebook?
Mr. Nix: absolutely not.
Facebook knew about the data collection but didn't do anything until the news came out.
Christopher Wylie and Paul-Oliver Dehaye inquiry into disinformation and fake news at UK Parliament.
Brittany Kaiser key player to Analytica, former director of Business Development for Cambridge Analytica
"Brittany Kaiser is not a whistler blower", Christopher Wylie
Paul Hider, Writer/Political Technologist advices her to share her material.
Kaiser worked for the republican party in USA, Ted Cruz and Brexit in UK.
First meeting in the Trump Towel: November 2015 she met with Alexander Nix and Corey Lewandowski, who was the campaign manager.
"Persuadables"
The Observer
Carole Cadwalladr
Google, democracy and the truth about internet search
Julian Wheatland, Former COO/CFO, Cambridge Analytica/SCL: Chris Wyle set out to kill Analytica. He worked for 9 months in 2014 then he went to pitch for the campaign and lost to them.
Who we are
We are a behavior change
Case:
Trinidad and Tobago: blacks and Indians. Analytica worked for the Indians. We went to the client and we said, "We want to target the youth." And we try to increase apathy. It was non political because the kids don't care about politics. It had to be reactive, because they're lazy. So we came up with this campaign, which was all about: Be part of the gang. Do something cool. Be part of a movement. And it was called the "Do So!" campaign.
[Kaiser] It means "I am not going to vote."
[Nix] "Do So!" "Don't vote!"
The Salute of Resistance that is know to all across Trinidad and Tobago. It is a sign of resistance against, not the government, against politics and voting. They are making youtube videos, graffitied the prime minister's house. "It was carnage." We knew that when it came to voting, all the Afro-Caribbean kids wouldn't vote, because they Do So! But all the Indian Kids would do what their parents told them to do, which is go out and vote. They had lots of fun doing this but they're not gonna go against their parents' will. And the difference in 18 - to 35 year-old turnout was like 40%. And that swung the election about 6%, which all we needed in an election that's very close.
They work on national campaigns. Kaiser was in all of it enjoying it and laughing aware of "oops we should talk about that" referring about Brexit.
[Brittany] "... these are classified as weapons-grade technology and it is actually illegal to use them without the permission of the British government. "
[Cadwalladr] It is psyOps. Psyops is psychological operations. Ant it's a term that the military uses to describe what you do in warfare which isn't warfare... SCL started out as a military contractor. SCL Defense.
We ave fairly substantial defense business. We actually train the British Army, the British Navy, the US Army, US Special Forces. We train NATO, the CIA, State Department, Pentagon. It is using research to influence behavior of hostile audiences. You know, how do you persuade 14- to 30-year-old Muslim boys not to join Al-Qaeda? Essentially communication warfare.
Cambridge Analytica was shut down but there are other companies.
Our earliest memories may remain blocked from our consciousness because we had no language skills at that time. A 2004 study traced the verbal development in 27- and 39-month old boys and girls as a measure of how well they could recall a past event. The researchers found that if the children didn't know the words to describe the event when it happened, they couldn't describe it later after learning the appropriate words [source: Simcock and Hayne].
Geoship is touting the bioceramic geodesic dome as the home of the future—and getting help on the rollout from Zappos, which wants to build some near its headquarters to give to the homeless.
Description:
If you have a vulnerable computer attached to the BIG BAD INTERNET, sooner or later your box will be compromised. Notice I prefer the term compromised to hacked. Hacking is a benign activity. You hack out of curiosity and [hopefully] with prior permission. Can this be done? Can I get into this box? How is he trying to keep me out? What stone has he left unturned? Woops: He has a bulletproof firewall but he left this one vulnerable cgi script in his httpd directory: HA! I'M IN! At that point the correct thing to do is to stop and notify the hackee. But once a hacker gets in, (especially if he is there without permission) the temptation to quietly mess around and cover his guilty tracks is usually overwhelming. Then it has gone from hacking to compromising someone else's box.
They earn more than 57 percent of undergraduate degrees and 59 percent of all master’s degrees.2
They earn 48.5 percent of all law degrees and 47.5 percent of all medical degrees.3
They earn 38 percent of Master of Business Administration and other generalist degrees and 49 percent of specialized master’s degrees.4
They account for 47 percent of the U.S. labor force5 and 52.5 percent of the college-educated workforce.6
And yet…
Although they hold almost 52 percent of all management- and professional-level jobs,7 American women lag substantially behind men in terms of their representation in leadership positions.
In the legal profession, they are 45 percent of associates but only 22.7 percent of partners and 19 percent of equity partners.8
In medicine, they represent 40 percent of all physicians and surgeons9 but only 16 percent of permanent medical school deans.10
In academia, they have earned the majority of doctorates for eight consecutive years11but are only 32 percent of full professors and 30 percent of college presidents.12
In the financial services industry, they constitute 61 percent of accountants and auditors, 53 percent of financial managers, and 37 percent of financial analysts.13 But they are only 12.5 percent of chief financial officers in Fortune 500 companies.14
Despite significant gains in November 2018, their representation in politics is just as paltry
As of January 2019:
Women will represent only 24 percent of members of Congress: 24 percent of the House and 23 percent of the Senate.15
They will hold 28 percent of seats in state legislatures.16
They will represent only 18 percent of governors17 and, as of August 2018, only 23 percent of the mayors of the 100 largest American cities.18
Women of color represent less than 9 percent of members of Congress.19
Women of color represent 2 percent of governors and, as of August 2018, only 10 percent of the mayors of the nation’s 100 largest cities.20
2018 was a watershed year for women in U.S. politics
The 2018 elections brought a surge of new women to local and statewide offices, with notable gains for young women and veterans; historic wins in Senate and governors’ races; and major breakthroughs for women of color in the House of Representatives.
A record of at least 125 women were elected to the U.S. Congress in November 2018.21
At least 102 women were elected to the House and 13 women to the Senate. Thirty-six were elected as first-time representatives and three as first-time senators.22
The number of women of color elected to Congress reached a historic high of 43, and at least three women elected identify as LGBTQ.23
The number of women serving in state legislatures will cross 2,000 for the first time.24
The number of women elected as governors increased from six to nine.25
Three states elected their first female governor: Janet Mills (D) in Maine, Kim Reynolds (R) in Iowa, and Kristi Noem (R) in South Dakota.26
Michelle Lujan Grisham (NM) became the first Democratic Latina governor in the United States.27
Stacey Abrams (D-GA) became the first black woman in the United States to be a majority party’s nominee for governor.28
Sharice Davids (D-KS) and Deb Haaland (D-NM) became the first Native American women elected to Congress.29
Ilhan Omar (D-MN) and Rashida Tlaib (D-MI) became the first Muslim women elected to Congress.30 Omar is also the first Somali American in Congress, and Tlaib is the first Palestinian American woman in Congress.31
Ayanna Pressley (D) became the first black woman elected to Congress from Massachusetts.32
Jahana Hayes (D) became the first black woman and the first black Democrat elected to Congress from Connecticut.33
Lauren Underwood (D-IL) is the first black woman to win a major party nomination, and subsequently be elected to Congress in her district, which is 85 percent white.34
Veronica Escobar (D) and Sylvia Garcia (D) became the first Latinas elected to Congress from Texas.35
Abby Finkenauer (D) and Cindy Axne (D) became the first women elected to the U.S. House of Representatives from Iowa.36
Sharice Davids (D) and Angie Craig (D) became the first openly LGBTQ members of Congress from Kansas and Minnesota, respectively.37
With the elections of Kyrsten Sinema (D) and Marsha Blackburn (R), women from Arizona and Tennessee, respectively, will serve in the U.S. Senate for the first time.38
Many of the women who ran in 2018 said they were inspired to do so by the 2016 defeat of Hillary Clinton, the first female candidate from a major political party to run for president. Clinton won the popular vote but lost in the electoral college. The collective history of women in U.S. politics over the past few decades has been similarly characterized by patterns of partial victory.
In the 1980s and early 1990s, the percentage of women running for office increased steadily, culminating in the so-called Year of the Woman in 1992, when the number of women in the U.S. Senate suddenly doubled—from two to four—and the number of women in Congress increased from 28 to 47.39
Women did not experience another great wave of political victories, however, until 2012, when a series of historic wins put an end to all-male state legislatures and brought six new women of color to Congress.40
The number of women in Congress only reached the triple digits—at 104—in 2014. And while the 2016 election cycle brought Clinton’s loss, it also led to a number of great breakthroughs: Nine new women of color were elected to Congress, bringing the total number of women of color in the U.S. House of Representatives and the U.S. Senate to 38—the highest level in U.S. history.41 And in 2017 and 2018, the number of women who decided to run for office skyrocketed. In the 2018, 53 women ran for the U.S. Senate, 476 women ran for the U.S. House of Representatives, 61 women ran for governor, and 3,415 women ran for state legislatures, all shattering previous records.42
In the 2018 midterm elections, the proportion of women of color running both for Congress and for state legislatures increased by 75 percent, while the share of white women running for Congress increased 36 percent, and the share of white women running for state houses went up 14 percent. 43
An uneven and imperfect revolution
In the late 20th century, women made more rapid advances in the private sector than they did in the political world. The gender wage gap narrowed, sex segregation in most professions greatly declined, and the percentage of women climbing the management ranks steadily rose.
In 1980, there were no women in the top executive ranks of the Fortune 100 companies; by 2001, 11 percent of those corporate leaders were women.44
Women’s share of board seats in S&P 1500 companies increased 7.2 percentage points, or 94 percent, from 1997 to 2009, and their share of top executive positions increased 2.8 percentage points, or 86 percent. The share of companies with female CEOs increased more than sixfold.45
Progress has been uneven, however. There have long been significant racial and ethnic differences in the rate of women’s advancement.
Women of color are 39 percent of the nation’s female population and 20 percent of the entire U.S. population.46
They constitute 38.3 percent of the female civilian labor force.
They are 18.2 percent of the total civilian labor force,47and are 18.5 percent of workers in S&P 500 companies.48
And yet…
Since the December 2016 departure of Ursula Burns as CEO of Xerox Corp., there have been no black women heading Fortune 500 companies.49
Indra Nooyi’s exit as CEO of PepsiCo in October 2018 leaves just two women of color CEOs in the Fortune 500.50
Women of color are only 4.7 percent of executive- or senior-level officials and managers in S&P 500 companies.51
As recently as 2013, more than two-thirds of Fortune 500 companies had no women of color as board directors.52
In recent decades, women’s overall gains have slowed
In the 1990s and 2000s, the narrowing of the gender wage gap decelerated, and the percentage of women in management jobs stagnated.53 And in recent years, the percentage of women in top management positions and on corporate boards has stalled.54
Women are just 5 percent of Fortune 500 CEOs—down from a record high of 6 percent in 2017.55
Women are only 7 percent of top executives in the Fortune 100 companies.56
Women occupy only 10 percent of top management positions in S&P 1500 companies.57
They hold just 19 percent of S&P 1500 board seats.58
They are just 26.5 percent of executive and senior officials and managers, 11 percent of top earners, and 4.8 percent of CEOs in S&P 500 companies.59
They are only 6 percent of all venture capital board representatives and lead only 9 percent of venture capital deals.60
In 2014, women were just 20 percent of executives, senior officers, and management in U.S. high-tech industries.61 As recently as 2016, 43 percent of the 150 highest-earning public companies in Silicon Valley had no female executive officers.62
Despite big hits, women in Hollywood still lack power
Although some of the most successful films of 2018 —“Black Panther,” “Crazy Rich Asians,” and “A Wrinkle in Time,” to name a few — showcased the talents of women of color both on screen and off screen, women’s representation in the film and television industry has stalled. Men still overwhelmingly create women’s on-screen image:
Women accounted for just 18 percent of all the directors, executive producers, producers, writers, cinematographers, and editors who worked on the top-grossing 250 domestic films of 2017.63
Women filled just 27 percent of all behind-the-scenes roles in broadcast network and streaming programs, and only 28 percent of behind-the-scenes roles in cable programs during the 2017-18 season.64
When there are more women behind the camera or in other key off-screen roles, the representation of women on screen is better: Films written or directed by women consistently feature a higher percentage of female characters with speaking roles.65
In sum
Women have outnumbered men on college campuses since 1988.66 They have earned at least one-third of law degrees since 198067 and accounted for one-third of medical school students by 1990.68 Yet, they have not moved up to positions of prominence and power in America at anywhere near the rate that should have followed.
In a broad range of fields, their presence in top leadership positions—as equity law partners, medical school deans, and corporate executive officers—remains stuck at 5 percent to 20 percent.69
Overall, there is an enormous gap between the fortunes of a small number of prominent women at the very top of their fields and the vast majority of women nationwide. A gulf is widening between American women and their counterparts in peer nations as well: Although the United States ranked first in women’s educational attainment on the World Economic Forum’s 2017 Global Gender Gap Index of 144 countries, it ranked 19th in women’s economic participation and opportunity and 96th in women’s political empowerment.70
Judith Warner is a senior fellow at the Center for American Progress. Nora Ellmann is a research assistant for women’s health and rights for the Women’s Initiative at the Center. Diana Boesch is a research assistant for women’s economic security for the Women’s Initiative at the Center.
National Center for Education Statistics, “Table 318.30. Bachelor’s, master’s, and doctor’s degrees conferred by postsecondary institutions, by sex of student and discipline: 2015-16,” available at https://nces.ed.gov/programs/digest/d17/tables/dt17_318.30.asp?current=yes (last accessed October 2018). ↩
National Center for Education Statistics, “Table 324.50. Degrees conferred by postsecondary institutions in selected professional fields, by sex of student, control of institution, and field of study: Selected years, 1985-86 through 2015-1613-14,” available at https://nces.ed.gov/programs/digest/d17/tables/dt17_324.50.asp?current=yes (last accessed October 2018). ↩
U.S. Bureau of Labor Statistics, “Labor Force Statistics from the Current Population Survey: Employment status of civilian noninstitutional population by age, sex, and race,” available at http://www.bls.gov/cps/cpsaat03.htm (last accessed November 2018). ↩
U.S. Bureau of Labor Statistics, “Labor Force Statistics from the Current Population Survey: Employment status of the civilian noninstitutional population 25 years and over by educational attainment, sex, race, and Hispanic or Latino ethnicity,” available at http://www.bls.gov/cps/cpsaat07.htm(last accessed November 2018). ↩
U.S. Bureau of Labor Statistics, “Labor Force Statistics from the Current Population Survey: Employed persons by detailed occupation, sex, race, and Hispanic or Latino ethnicity,” available at http://www.bls.gov/cps/cpsaat11.htm (last accessed November 2018). ↩
U.S. Bureau of Labor Statistics, “Labor Force Statistics from the Current Population Survey: Employed persons by detailed occupation, sex, race, and Hispanic or Latino ethnicity.” ↩
Center for American Women and Politics, “Results: Women Candidates in the 2018 Elections”; Center for American Women and Politics, “Women of Color in Elective Office 2018,” available at http://www.cawp.rutgers.edu/women-color-elective-office-2018 (last accessed November 2018). ↩
Center for American Women and Politics, “Results: Women Candidates in the 2018 Elections.” ↩
Ibid. Four House elections with a female candidate remain undecided as of the publication of this fact sheet. The Mississippi Senate election will head to a runoff, with incumbent Sen. Cindy Hyde-Smith (R) possibly adding to the total number of female senators elected in 2018.↩
A firestorm erupted in 1988 when Bob Gasoi's controversial murals debuted on the facade of the 346 Commercial Street, Provincetown landmark, Shop Therapy.
Shop owners had begun the annual off-season ritual of boarding up the windows and doors of stores up and down Commercial Street in anticipation of Cape Cod's punishing winter. It was innocently suggested by the town council that perhaps the blight could be brightened up by using the rows of ugly plywood as a canvas for art. The Gasoi murals were created on sheets of plywood and then screwed to Shop Therapy's exterior. It was not long before the entire building disappeared behind one giant collage of 4x8s which became one big problem when the community tried to resolve the differences between the mural supporters and its detractors.
A visit to our retail store on Commercial Street in the heart of Provincetown is designed to feel like home. That shoppers sit on the porch or gather on the terrace under the chestnut tree delights us. The shop is also a laboratory in which we can play with new furniture designs, colorful fabrics and inspirational ideas. We work hard to always keep it fresh and unexpected. A casual visit by our customers can spark ideas for them and hopefully enhance their spaces at home. Comfort, style and a sense of well being is what Shor Home Furnishings is all about. We feature brands that compliment seaside living style including Hickory Chair, Palecek, Michael Aram, Visual Comfort and American Leather. In addition we collect one of a kind pieces and original works of art.
Design and Architecture Services: Our design projects are client specific and reflect their personalities and taste. Whether modern, traditional or a mix of the two we strive to understand the client’s needs and produce a space that is the perfect fit.
The critical meeting is the first consultation. It is a conversation to uncover our client’s personality, their likes and dislikes, a favorite style of furnishings or a color that brings them to life. We can then craft an idea book and offer a plan to create the perfect space- a home to love.
Our scope of projects range from a bathroom or kitchen makeover to complete renovations and original architecture. Services include space planning, color and materials selections, fabrications of draperies, custom rugs and furnishings, flooring and lighting.
A special moment for us is the design reveal. When we conduct a walk-through of the completed project with our clients and experience the excitement of a transformed new space. The joy is absolutely priceless!
Horizon Line Series | The Horizon Line series is a contemplation of the steadfast and beautiful horizon looking over the sea. While the colors change in season and weather, the line is always there, aways a steadying point, fixed in the distance. I made these paintings after seeing a book called Still: Oceanscapes by Debra Bloomfiel and being mesmerized by how one place can change so dramatically throughout the year. These are my first series of seascapes painted solely with encaustic. Catherine M Weber wiki
iSprawl is the youngest and fastest sibling of Autonomous version of Sprawl robot family. I joined BDML at the end of this Office of Naval Research project and designed iSprawl for the first creation at Stanford.
Sprawl robots are designed by inspiration based on study of cockroaches. - Watch iSprawl's running on ground. Other movie clips are on video page
Whereas other sprawl robots utilize pneumatic system, iSprawl is equipped with battery and electric motor and power transmission system that convert rotary motion to reciprocal leg thrust. What most makes iSprawl unique is push-pull cable transmission system. Since Sprawl family turn its orientation by rotation of their leg with respect to hip joint, power transmission path is not fixed. Which is frequent problem in legged robot with centered engine.
Usage of steel cable as pulling transmission is very common
as you can find very easily in bicycle brake and car throttle. iSprawl's cables, however, thrust and pull the legs in high speed
(up to 17Hz) without significant energy loss. This enables
iSprawl's light and fast movement of legs leading to fast
locomotion up to 15 body-lengths/sec(2.3m/s).
Predecessor of iSprawl, the first sprawl robot that operates with autonomous power. It uses hydraulic power transmission system. The idea was to explore hydaulic power transmission to distribute power to the legs. The tubes contain water and the system works like hydraulic brakes on a car, with a single master piston and slave pistons at each leg. Aqua Sprawl is assembled in a bathtub to prevent air bubbles.
After many design iterations, including remachining the original Sprawlita pistons to put in double seals to handle negative pressure on the return stroke, a version of Aqua Sprawl was produced that ran fairly well: A movie of Aqua-Sprawl
Although Aqua Sprawl ran reasonably well, there is a fundamental limitation to the achievable speed because while retracting the pistons, only atmospheric pressure is available. On the other hand, this could be a good design for underwater use!
Walking upside-down requires a careful balance of adhesion and weight, and specialized trekking tools to combat the constant tug of gravity.
Each fly foot has two fat footpads that give the insect plenty of surface area with which to cling. The adhesive pads on the feet, called pulvilli, come equipped with tiny hairs that have spatula-like tips. These hairs are called setae.
Scientists once thought that the curved shape of the hairs suggested that flies used them to grip onto the ceiling. In fact, the hairs produce a glue-like substance made of sugars and oils.
Sticky proof
A research team from the German Max Planck Institute for Metals Research recently studied more than 300 species of wall-climbing insects and watched them all leave behind sticky footprints.
Mystery Monday
Each Monday, this LiveScience series explores an amazing aspect of the world around you. Previous articles:
Mystery Monday
Each Monday, this LiveScience series explores an amazing aspect of the world around you. Previous articles:
"There are over one million insect species," team leader Stanislav Gorb told LiveScience. "We suppose that all of them have the secretion, but it is difficult to be 100 percent sure."
Gorb presented the findings at the Annual Meeting of the Society for Experimental Biology in April.
Flies need sticky feet to walk on ceilings, but not so sticky that they get stuck upside down. So each foot comes with a pair of claws that help hoist the gooey foot off the wall.
Flies use several different techniques to get unstuck: pushing, twisting, and peeling its footpads free.
"Methods involving peeling are always the best, because they require less energy to break the contact," Gorb said.
The combination of the feet hairs' rounded tips, the oily fluid, and a four-feet-on-the-floor rule help the inverted insect take steps in the right direction.
Lessons for robofly
Following in the fly's footsteps, robots are on their way to climbing walls.
Gorb's research team worked with a robotics group from Case Western Reserve University to design robotic feet that mimic a fly's footing.
On the bottom of the feet of a 3-ounce robot that's all legs, scientists tacked on a sticky, furry manmade material that resembles the hairy surface of a fly foot. The researchers also taught the robot how to gently peel its foot off a glass wall, just like a demure insect.
"It's the first time a robot has climbed glass in a way that was inspired by an animal," said mechanical engineer Roger Quinn.
Hummingbird Facts and History
Author: Johann Erickson
Hummingbird Facts and History
The following provides a few hummingbird facts and a bit of the history of hummingbirds. Sure to interest those who enjoy watching and feeding these tiny jewels of the garden.
The oldest historical mention of hummingbirds dates back to the Taino Native Americans, around the time of Columbus.
The Taino believe that hummingbirds are the spreaders of life on Earth, and their warriors were known as Colibir, or Hummingbird warriors,
because they are a peaceful bird that will defend their territory with the heart of an eagle.
How long they have been in America is unknown, but they have delighted bird watchers for many years, with their quick dashes into the garden, and the shine of the sun on brilliant feathers.
While there actually are duller colored birds, the ruby-throated hummingbirdis the most commonly recognized for its iridescent feathering, and dazzling ruby-red throat.
The color though, is not all it seems.
Hummingbirds get their unusual coloring from the fact that not all feathers are pigmented, or colored. In the duller colors, including the Rufous Hummingbird, the brown hue is actual pigment in the feather structure.
The oldest historical mention of hummingbirds dates back to the Taino Native Americans, around the time of Columbus.
The Taino believe that hummingbirds are the spreaders of life on Earth, and their warriors were known as Colibir, or Hummingbird warriors,
because they are a peaceful bird that will defend their territory with the heart of an eagle.
How long they have been in America is unknown, but they have delighted bird watchers for many years, with their quick dashes into the garden, and the shine of the sun on brilliant feathers.
While there actually are duller colored birds, the ruby-throated hummingbirdis the most commonly recognized for its iridescent feathering, and dazzlig ruby-red throat.
The color though, is not all it seems.
Hummingbirds get their unusual coloring from the fact that not all feathers are pigmented, or colored. In the duller colors, including the Rufous Hummingbird, the brown hue is actual pigment in the feather structure.
In the ruby-throated species, light refracting through the feather segments, breaking it up much like a prism would. Only certain levels of color will be seen by the human eye, and that color will change with every movement of the feather, or angle of the light striking it.
This is one of the features that makes them so charming to watch as they flit around a garden or feeder.
Hummingbirds are very fast, traveling at an average 25 miles per hour, with wingbeats of anywhere from 10-15 per second in the Giant Hummingbird, up to 80 per second by the Amethyst Woodstar. The ruby-throated hummer falls into the middle range, at about 53 beats per second.
To sustain such rapid and prolonged activity, the hummingbird's heart must beat accordingly. For birds that are hot, or sleepy, that can be as low as 50-180 beats per minute, but a heart rate of an amazing 1360 beat per minute has been recorded in a Blue-Throated Hummingbird.
All this activity requires a humming bird to eat almost continually, to fuel the activity that will maintain its 105-109F body heat. That means dining as many as 15 times an hour, on high-energy food.
In volume, they consume up to eight times their body weight a day. But reduce the nectar to a solid by eliminating the water, and it would amount to their own bodyweight.
A hummingbird can starve to death in as little as two hours, if still active. That makes rescue of birds trapped in garages or other enclosed areas, imperative within a short time.
At night, their "thermal generators" shut down as they rest, and allow their body temperature to drop, so that less energy is used up while they sleep.
If you enjoy watching these delightful little birds, and are also an enthusiastic gardener, why not plant clumps of flowers or bushes, to bring them into your yard?
Hummingbirds are creatures of habit, and will develop their own paths to food, checking them frequently and on a daily basis.
Once they find out you have goodies, they'll return over and over. Other hummers will follow, and you may then get to see hummingbird behavior at its worst, as they dive at each other to protect their food sources.
Good choices of food producing plants for hummingbirds include such trees or bushes as Azaleas, Mimosa, Weigela, Cape Honeysuckle and Flowering Quince. Another semi-permanent attraction is a perennial bed with Bee Balm, Columbine, Lupine, Coral Bells and Canna.
You can also plant a wide range of annuals like Fuschia, Impatiens, Petunias and Firespike, but consider growing some of your own plants from seed, as many flowers that are nursery grown, tend not to have as much nectar.
Got an interesting story about Hummingbirds nesting and feeding in your backyard? Why not Share it With Our Visitors. Got pictures? We Love Pics - To share your story Click Here
Hummers will be overjoyed to discover this bonanza of blooms, and the tiny bugs that constitute the protein source of their diet.
To make sure you enjoy these little feathered friends for the whole season, hang some hummingbird feeders around your patio or gardens.
But make sure there is a bit of distance between them, to avoid the squabbles, which can be quite a sight!
Because hummers are attracted to red flowers, you'll find many of the hummingbird feeders available, are also colored red.
This isn't an absolute necessity, but it can be a bright spot in your garden. And the feeders come in all kinds of charming shapes from a hanging bunch of grapes, to a giant strawberry.
Commercial powdered "food" formula is available, but you can easily make your own by combining one part sugar to four parts water, and boiling it for two minutes, then cooling and storing in the fridge.
Never use honey, which can ferment, or red dye, which can be harmful to the birds.
Only fill your hummingbird feeders to the one-third or halfway mark, as it would take many birds to empty the contents, and the feeders will need cleaning every few days to prevent the occurrence of mold.
Wash in mild dish detergent, with no more than 10% bleach, and rinse several times. If you have mold inside the feeder and can't reach it with a bottle brush, put some sand in with the water, and swish that back and forth, until the mold is rubbed off.
Hummingbird Trivia Facts
The hummingbird is so small, that an insect, the Praying Mantis is its natural enemy.
They are the only bird that can hover, and fly backwards as well as straight up or down
Hummingbirds can't walk
The average life of a hummingbird is 3-4 years, although one specimen was caught in 1976 in Colorado, banded, and captured again in 1987
Migration Fact
Often the question is asked, "do hummingbirds ride on the backs of geese during migration?" While this may sound like a reasonable solution, it is not true.
Hummingbirds that migrate, do so on their own wing power.
When Do Hummingbirds Leave For Winter
Leaving your feeders up as long as they are still coming will help them fuel up before their 600 mile journey across the Gulf of Mexico.
A hard date isn't possible since there are several factors that determine migration timing. Ruby-throated hummingbirds are usually what people are asking about.
The best advice I can give is to leave feeders up an additional two weeks past the last time you saw any feeding. Usually sometime in October. But don't hold me to that.
An understanding of the hummingbirds nesting, mating, and feeding habits may aid you in attracting and keeping these small wonders in your backyard garden and around your bird feeders.
These birds may be small but they don't always seem to know it. These tiny birds have the habit of staunchly defending their territory at the bird feeder during the fall migration. Males will chase other males away letting only his females and young to feed. (maybe not even them)
Description
The Ruby-throated only measures 3 3/4 inches long, and is the widest-ranging of all North American hummingbirds.
This green and scarlet little bird is the only one likely to be seen east of the Mississippi River and certainly the only to breed in the area.
The male Ruby-throated has green upperparts and a iridescent red throat. Although depending on light, the throat may appear black. The breast and middle are whitish.
Female Ruby-throats have green upperparts and whitish underparts.
Nectar Recipe
Humming Bird Sugar Water Mixture
A feeder filled with sugar water will attract this relatively tame visitor. Just mix 1 part white sugar with 4 parts water. Boil the mixture 3 or 4 minutes and let cool. Fill your feeder and store any of the leftover nectar recipe in the refrigerator. Your feeders need to be cleaned throughly every 3-4 days.
Feeding Habits What Hummingbirds Eat
These birds must eat all day long just to survive. In addition to nectar from flowers and your sugar water feeder, these birds eat small insects, beetles, ants, aphids, gnats, mosquitoes, and wasp.
As you can see, it's to your advantage to attract these jewels to your backyard.
As you can see, it's to your advantage to attract these jewels to your backyard.
Got an interesting story about these birds in your backyard? Please Share it With Our Visitors. Got a picture? - Even Better! To share your Click HereTo Read What Others Have Said Click Here
When To Take Feeders Down
Many ask the question "When do I need to take my feeder down?" A common myth is that leaving your feeders out too long will cause the hummers to stay longer than they should. This just isn't true.
The recommended best time to stop feeding hummingbirds is two weeks after you no longer see them visiting your yard and feeders. As long as you still see them visiting keep providing for them. This will allow them to store fat resources for their long migration.
If a freeze is predicted, bring your feeder indoors for the night and return it as early in the morning as possible. They need to refuel after a cold night.
How They Stay Warm
We're often ask "how do hummingbirds stay warm at night?" Well, along with the normal things birds do such as puffing out feathers for better insulation and finding sheltered locations to roost, these birds have the ability to reduce their temperature and slow their metabolism down. This is referred to as "Torpor".
Think of it as a mini hibernation just to get through a cold night. They are not the only birds capable of doing this but neither can all birds do this.
We get emails from visitors who find these birds in a state of torpor and hanging upside down on the feeder. Other times, early in the morning, some people have picked them off the feeder thinking they were ill.
It's is always best to wait and see. Let them come out of this state at their own pace so that no harm is done to the bird.
Nesting Habits
When looking for Ruby-throats nest, you'll need a keen eye. Its nest is a cup of plant down and spider web, covered with flakes of lichen, placed 5-20 ft. above ground. Look for a horizontal limb with a slight downslope.
Two white eggs are incubated for about 20 days by the female humming bird and the young will leave the nest 20-22 days after hatching.
These birds don't reuse a nest from season to season but may reuse it in the same season for its second brood. They often return to the same territory from year to year and maybe to the same shrub or tree. Nest are very small and are easily destroyed by winter weather but remember, it's illegal to remove or take any nest that you may find.
May attempt 2 broods each season.
Here are a few interesting facts and behavioral habits:
In spring, the male defends his territory of about 1/4 acre.
In dive displays, he flies in a U shape, rising 10-40 ft. on each side.
After mating, the female builds the nest and raises the young alone.
The flight speed has been clocked at 25 mph and estimated at up to 50 mph
The average man burns about 3,500 calories a day. If the daily output of these birds were calculated for a 170-pound man, he would need to burn about 155,000 calories
Hummingbirds do not ride on the backs of geese during migration. They migrate on their own power.
Generally, adults birds migrate first, while the young continue to feed and grow before migrating.
Some Ruby-throats migrate 600 miles across the Gulf of Mexico. During fall they will store enough fat to double their weight in order to make the long trip. That's quite a feat for a bird that weighs about the same as 2 1/2 paper clips!
Attracting Hummingbirds What Are The Best Flowers And Plants
When it comes to attracting hummingbirds, everyone wants to know what types of flowers and plants do these birds like best. And with good reason These birds can be a joy to watch as they hover and flit from flower to flower.
I'm going to guess that you already know the very best way of attracting these birds to visit your yard is by providing a feeder. But now you're getting serious and want to provide more natural food sources.
You want to create a hummingbird garden, and I say, good for you! You're taking the next step to providing for these birds in a natural kind of way. But before you run out and get a bunch of flowers they love, A word of caution.
Be careful about what plants you choose. While the chart below offers several ideas, be sure to talk things over with your garden center folks.
Many plants that work the best for attracting Hummingbirds can get out of control and overtake your yard and garden. Consider the space you have to devote to this cause. Some vines like Trumpet Vine will pop up with little trees all over your yard if it isn't controlled. I speak from experience.
Some Columbine varieties will self sow and you'll end up with more than you want. On the other hand, it's a great way to add more without any more expense.
I would suggest that you also create several different locations throughout your property to plant flowers and shrubs. The reason for this is that Hummingbirds can be very territorial when it comes to feeding locations. If you provide several little pockets for them, all will have a better chance to feed and your birds will love you for this.
Don't forget that these birds are with us well into fall. Make sure that you offer nectar rich flowers that bloom late into the season. Migrating birds will need to bulk up for their long flights over the Gulf.
The most important part of attracting hummingbirds with plants is to plan. And of course, always provide Hummingbird feeders. That way you'll never have to worry if there is enough in the garden to take care of them.
Something to Keep in Mind
In general, birds have a weak sense of smell and hummingbirds are no exception.
Discovering food sources by sight rather than smell. With this in mind, fragrance of flowers has little effect on whether hummingbirds will like them.
Nectar rich flowers will be more inticing to them.
The chart below shows a few nectar rich plants that will help in attracting hummingbirds.
Favorite Plants For Attracting Hummingbirds
Annuals
Perennials
Vines
Shrubs
Fuchsia
Bee Balm
Coral Honeysuckle
Butterfly Bush
Impatients
Canna
Cypress Vine
Flowering Quince
Jacobiana
Cardinal Flower
Morning Glory
Lantana
Jewelweed
Coral Bells
Scarlet Runner
Manzanita
Petunia
Four O'Clocks
Trumpet Creeper
Mimosa
Salvia
Foxglove
Canary creeper
Red Buckey
Shrimp Plant
Hosta
Carolina jasmine
Tree Tobacco
Snapdragon
Lupine
Glory vine
Turks Cap
Nicotiana
Columbine
Cypress vine
Weigela
When gardening to attract hummingbirds, select a variety of flowers and plants with different bloom times, spring, early summer, late summer, and fall. Read the labels of any plants you purchase or ask the staff at your local garden center for this type of information.
Avoid using chemicals especially pesticides around any flowers you select for these birds. Hummingbirds eat tiny insects as part of their diet and these can kill the adults and their young.
You may want to provide nesting materials to encourage these birds to nest in your backyard.
Got an interesting story about Hummingbirds in your backyard? Please Share it With Our Visitors. Got a picture? - Even Better! To share your story or read what others said Click Here
Downy like materials, spiderwebs, ferns, moss and lichens are the prefered nesting materials of the hummingbird. Willow and eucalyptus trees provide downy like materials as mentioned above.
Water
Hummingbirds do not use traditional types of birdbaths. Instead, they prefer ones that spray a mist or have fountains. Rather than splashing in a bath like most of our back yard birds, Hummingbirds fly in and out of a spray of water. You may want to consider adding a misting type. They are usually sold for human use while sunbathing.
I see them around in the summer. They hook up to a hose and intermittently spray a mist. Probably not a good idea for humans but will work well for the birds.
Place them near your flowers. I would only use it while I was able to watch as it's probably not very economical.
By incorporating a few of these suggestions you'll greatly improve your chances of having hummingbirds filling your yard all summer long.