Solution Idea!
#include <bits/stdc++.h> using namespace std; class HeapNode_Min { // Tree node of Huffman public: //Add data members here. char d; unsigned f; HeapNode_Min *l, *r; HeapNode_Min(char d, unsigned f = -1) { //Complete the body of HeapNode_Min function this->d = d; this->f = f ; this->l = NULL; this->r = NULL; } }; class Analyze { // two heap nodes comparison public: bool operator()(HeapNode_Min* l, HeapNode_Min* r) { //add return before statement and statement is completed. return (l->f > r->f); //Complete this statement } }; void display_Codes(HeapNode_Min* root, string s) // To print codes of huffman tree from the root. { if (!root) return; if (root->d != '$') cout root->d "\t: " s "\n"; display_Codes(root->l, s + "0"); display_Codes(root->r, s + "1"); //Complete this statement by passing arguments } void HCodes(char data[], int freq[], int s) // builds a Huffman Tree { HeapNode_Min *t,*r, *l ; // top, right, left priority_queue<HeapNode_Min*, vector<HeapNode_Min*>, Analyze> H_min; int a=0; while (a<s){H_min.push(new HeapNode_Min(data[a], freq[a])); ++a;} while (H_min.size() != 1) { l = H_min.top(); H_min.pop(); r = H_min.top(); H_min.pop(); t = new HeapNode_Min('$', r->f + l->f); t->r = r; t->l = l; H_min.push(t); } display_Codes(H_min.top(), ""); } int main() { int frequency[] = { 3, 6, 11, 14, 18, 25 }; char alphabet[] = { 'A', 'L', 'O', 'R', 'T', 'Y' }; //Complete this statement by passing data type to both sizeof operators int size_of = sizeof(alphabet) / sizeof(*alphabet); cout"Alphabet"":""Huffman Code\n"; cout"--------------------------------\n"; //Call Huffman_Codes function. HCodes(alphabet, frequency, size_of); return 0; }PSY404 GDB 1 Solution and Discussion
-
Life is so dear to all of us but sometimes we came to know about people who end their lives by themselves. As being student of Psychology explain why people tend to indulge in that type of behavior. What are the causes and motives behind it? Justify with sound logical arguments and examples.
-
@zareen said in PSY404 GDB 1 Solution and Discussion:
why people tend to indulge in that type of behavior.
What are the causes and motives behind it?I) Physiological Motives:
a. Hunger motive:
We eat to live. The food we take is digested and nutritional substances are absorbed. The biochemical processes get their energy from the food in order to sustain life. When these substances are exhausted, some imbalancement exists.We develop hunger motive in order to maintain homeostasis. This is indicated by contraction of stomach muscles causing some pain or discomfort called hunger pangs. Psychologists have demonstrated this phenomenon by experiments.
b. Thirst motive:
In our daily life regularly we take fluids in the form of water and other beverages. These fluids are essential for our body tissues for normal functioning. When the water level in the body decreases we develop motive to drink water.Usually thirst motive is indicated by dryness of mouth. Experiments by psychologists have shown that just dried mouth getting wetted is not enough. We need to drink sufficient quantity of water to satiate our thirst.
c. Need for oxygen:
Our body needs oxygen continuously. We get it through continuous respiration. Oxygen is necessary for the purification of blood. We cannot survive without regular supply of oxygen. Lack of oxygen supply may lead to serious consequences like damage to brain or death.d. Motive for regulation of body temperature:
Maintenance of normal body temperature (98.6°F or 37.0°C) is necessary. Rise or fall in the body temperature causes many problems. There are some automatic mechanisms to regulate body temperature, like sweating when the temperature rises above normal or, shivering when it falls below normal.These changes motivate us to take necessary steps. For example, opening of windows, put on fans, take cool drinks, remove clothes, etc., when the temperature increases to above normal level; and closing doors and windows, wear sweaters, take hot beverages when temperature falls down. In this way we try to regulate the body temperature.
e. Need for sleep:
Sleep is an essential process for normal functioning of body and mind. When our body and mind are tired they need rest for rejuvenation of energy. It is observed that there is excess accumulation of a toxin called ‘Lactic acid’ when tired.After sleep it disappears and the person becomes active. Sleep deprivation also leads to psychological problems like confusion, inability to concentrate, droopy eyelids, muscle tremors, etc.
f. Need for avoidance of pain:
No organism can continue to bear pain. Whenever we experience pain we try to avoid it. We are motivated to escape from painful stimulus. For example, when we are under hot sun we go to shade. When something is pinching we avoid it.g. Drive for elimination of waste:
Our body cannot bear anything excess or anything waste. Excess water is sent out in the form of urine or sweat. So also digested food particles after absorption of nutritional substances are sent out in the form of stools. We experience discomfort until these wastes are eliminated.h. Sex motive:
This is a biological motive, arises in the organism as a result of secretion of sex hormones-like and rogens and estrogens. Sex need is not essential for the survival of the individual, but it is essential for the survival of the species. However, fulfillment of the sex need is not like satisfying hunger or thirst.The society and the law exercise certain codes of conduct. Human being has to adhere to these rules. Usually this need is fulfilled through marriage.
i. Maternal drive:
This is an instinct or an inborn tendency. Every normal woman aspires to become a mother. Psychologists haveMotivation, Emotion and Attitudinal Processes 123 learnt from related studies that, this is a most powerful drive. That is why in many cases the women who cannot bear children of their own, will sublimate that motive and satisfy it through socially acceptable ways, like working in orphan schools, baby sittings or adopting other’s children.


100% Off on Your FEE Join US! Ask Me How?


