- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
DS and Algorithm_session_03_doubly lingked list.ppt
* * * * * * * * * * Tell the students that a circular linked list can be a singly circular or a doubly circular linked list. * * * * Ask the students to write the algorithm first and then come up with the solution. * * * * * * * Tell the students that inserting a node in the middle of a circular linked list is same as that of a singly-linked list. This is because the only difference between the two lists is with the arrangement in the address field of the last node. Therefore, the process of insertion of a node at the end of the two lists is different. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * In this slide you need to show the calculation to determine the sum of an arithmetic progression for bubble sort algorithm. Refer to student guide. * * * * * * * * * * * * * * * -8 8 theList 3 14 0 -1 q p(x)=3x14-8x8+6x2+2 输入多项式的项,建立多项式: 6 2 (3,14) 2 0 (-8,8) (6,2) (2,0) Output函数将多项式按降幂方式送输出流。 void Polynominal::Output(ostream out)const { int first=1; Term *p=theList-link; coutThe polynominal is:\nendl; for ( ; p!=theList; p=p-link) { if (!first (p-coef0)) out+; first=0; out*p; // 调用Term类上重载的“”操作。 } cout\nendl; } 3 14 px -8 8 2 0 6 2 0 -1 3. 多项式相加——实现q(x)?q(x)+p(x) 设p和q分别指向多项式p(x)和q(x)的当前正进行比较的项,初始 时分别指向两多项式中最高幂次的项。q1指向q的前驱结点。 对p(x)进行遍历,根据指针p、q的exp域的大小情况做相应处理: ①p-expq-exp 则q指示的项应成为结果多项式中的一项,所以q1和q右移一项。 ②p-exp==q-exp 则系数相加,即q-coef=q-coef+p-coef。如果q-coef不为零,则指 针q1和q 均右移一个结点;否则从q(x)中删除q指示的结点。 ③p-expq-exp 则复制p所指示的结点,并将其插在 q1之后。 指针p右移一项; 重复上述处理,直到p(x)中全部结点都处理完结束。 p q1 3 14 px -8 8 2 0 6 2 0 -1 q 6 12 qx 8 8 3 2 -2 6 0 -1 3 14 qx 2 10 2 0 -4 8 0 -1 一元整系数多项式相加 void Polynominal::PolyAdd(Polynominal r) //将多项式r加到多项式this上 { Term* q,*q1=theList,*p; //q1指向表头结点 p=r.theList-link; //p指向第一个要处理的结点 q=q1-link; //q1是q的前驱,p和q就指向两个当前进行比较的项 while (p-exp=0) //对r的单循环链表遍历,直到全部结点都处理完 { while (p-expq
您可能关注的文档
最近下载
- 第12课《鱼纹话吉祥》课件(共30张PPT)岭南美版(2024)初中美术七年级上册(内嵌视频).pptx VIP
- 纱布msds急救措施.docx VIP
- 吸塑生产工艺介绍.pptx VIP
- 药理学:治疗充血性心力衰竭药.ppt VIP
- 教师如何做课题.ppt VIP
- 儿童绘本成语故事《邯郸学步》教育教学PPT课件.pptx VIP
- Q∕CR 9247-2016铁路隧道工程风险管理技术规范.pdf VIP
- 必威体育精装版国家执业药师工作年限证明-模板.doc VIP
- 03J203 平屋面改坡屋面建筑构造.docx VIP
- 标准图集-14J938-抗爆、泄爆门窗及屋盖、墙体建筑构造.pdf VIP
有哪些信誉好的足球投注网站
文档评论(0)